Document

Inheritance: java.lang.Object, com.aspose.pdf.IVentureLicenseTarget, com.aspose.pdf.ADocument

All Implemented Interfaces: com.aspose.pdf.IDocument

public final class Document extends ADocument implements IDocument

Class representing PDF document

Constructors

Constructor Description
Document() Initializes empty document.
Document(byte[] input) Initialize new Document instance from the input byte array.
Document(InputStream input) Initialize new Document instance from the input stream.
Document(InputStream input, String password) Initialize new Document instance from the input stream.
Document(System.IO.Stream input) Initialize new Document instance from the input stream.
Document(InputStream input, String password, boolean isManagedStream) Initialize new Document instance from the input stream.
Document(InputStream input, boolean isManagedStream) Initialize new Document instance from the input stream.
Document(InputStream input, LoadOptions options) Opens an existing document from a stream providing necessary converting to get pdf document.
Document(String filename, LoadOptions options) Opens an existing document from a file providing necessary converting to get pdf document.
Document(System.IO.Stream input, String password) Opens an existing document from a stream.
Document(String filename) Just init Document using filename .
Document(String filename, String password) Initializes new instance of the Document class for working with encrypted document.
Document(String filename, String password, boolean isManagedStream) Initializes new instance of the Document class for working with encrypted document.

Methods

Method Description
getPageInfo() Gets the page info.
setPageInfo(PageInfo value) Sets the page info.
getDestinations() Gets the collection of destinations.
getPdfFormat() Gets pdfa format
getFontUtilities() IDocumentFontUtilities instance
removePdfaCompliance() Remove pdfa compliance from the document
getCollection() Gets collection of document.
setCollection(Collection value) Sets collection of document.
getEngineDoc() Instance of IPdfDocument used to access to internal document structure.
getVersion() Gets a version of Pdf from Pdf file header.
getOpenAction() Gets action performed at document opening.
setOpenAction(IAppointment value) Sets action performed at document opening.
isHideToolBar() Gets flag specifying whether toolbar should be hidden when document is active.
setHideToolBar(boolean value) Set flag specifying whether toolbar should be hidden when document is active.
isHideMenubar() Gets flag specifying whether menu bar should be hidden when document is active.
setHideMenubar(boolean value) Sets flag specifying whether menu bar should be hidden when document is active.
isHideWindowUI() Gets flag specifying whether user interface elements should be hidden when document is active.
setHideWindowUI(boolean value) Sets flag specifying whether user interface elements should be hidden when document is active.
isFitWindow() Gets flag specifying whether document window must be resized to fit the first displayed page.
setFitWindow(boolean value) Sets flag specifying whether document window must be resized to fit the first displayed page.
isCenterWindow() Gets flag specifying whether position of the document’s window will be centered on the screen.
setCenterWindow(boolean value) Sets flag specifying whether position of the document’s window will be centered on the screen.
isDisplayDocTitle() Gets flag specifying whether document’s window title bar should display document title.
setDisplayDocTitle(boolean value) Sets flag specifying whether document’s window title bar should display document title.
getPages() Gets collection of document pages.
getOutlines() Gets document outlines.
getActions() Gets document actions.
getForm() Gets Acro Form of the document.
getEmbeddedFiles() Gets collection of files embedded to document.
getDirection() Gets reading order of text: L2R (left to right) or R2L (right to left).
setDirection(int value) Sets reading order of text: L2R (left to right) or R2L (right to left).
getPageMode() Gets page mode, specifying how document should be displayed when opened.
setPageMode(int pageMode) Sets page mode, specifying how document should be displayed when opened.
getNonFullScreenPageMode() Gets page mode, specifying how to display the document on exiting full-screen mode.
setNonFullScreenPageMode(int value) Sets page mode, specifying how to display the document on exiting full-screen mode.
getPageLayout() Gets page layout which shall be used when the document is opened.
setPageLayout(int value) Sets page layout which shall be used when the document is opened.
getFileName() Name of the PDF file that caused this document
getInfo() Gets document info.
getMetadata() Document metadata.
getLogicalStructure() Gets logical structure of the document.
processParagraphs() Stores document into stream.
save(System.IO.Stream output) Stores document into stream.
save(OutputStream output) Stores document into stream.
save(String outputFileName) Saves document into the specified file.
exportAnnotationsToXfdf(String fileName) Exports all document annotations to XFDF file
sendTo(DocumentDevice device, OutputStream output) Sends the whole document to the document device for processing.
sendTo(DocumentDevice device, int fromPage, int toPage, OutputStream output) Sends the certain pages of the document to the document device for processing.
sendTo(DocumentDevice device, String outputFileName) Sends the whole document to the document device for processing.
sendTo(DocumentDevice device, int fromPage, int toPage, String outputFileName) Sends the whole document to the document device for processing.
removeMetadata() Removes metadata from the document.
importAnnotationsFromXfdf(String fileName) Imports annotations from XFDF file to document.
validate(String outputLogFileName, PdfFormat format) Validate document into the specified file.
convert(String outputLogFileName, PdfFormat format, int action) Convert document and save errors into the specified file.
validate(OutputStream outputLogStream, PdfFormat format) Validate document into the specified file.
convert(String outputLogFileName, PdfFormat format, int action, int transparencyAction) Convert document and save errors into the specified file.
convert(Document.CallBackGetHocr callback) Convert document to searchable document.
convertWithSkippingErrors(Document.CallBackGetHocr callback) Convert document to searchable document and skip errors of hochr that can not be converted.
convertInternal(System.IO.Stream outputLogStream, PdfFormat format, int action) Convert document and save errors into the specified stream.
convert(OutputStream outputLogStream, PdfFormat format, int action) Convert document and save errors into the specified stream.
convert(PdfFormatConversionOptions options) Convert document using specified conversion options
convert(int fixup, OutputStream outputLog) Convert document by applying the Fixup.
convert(int fixup, OutputStream outputLog, boolean onlyValidation, Object[] parameters) Convert document by applying the Fixup.
convert(int fixup, String outputLog) Convert document by applying the Fixup.
convert(int fixup, String outputLog, boolean onlyValidation, Object[] parameters) Convert document by applying the Fixup.
flatten() Removes all fields from the document and place their values instead.
getCryptoAlgorithm() Gets security settings if document is encrypted.
encrypt(String userPassword, String ownerPassword, DocumentPrivilege privileges, int cryptoAlgorithm, boolean usePdf20) Encrypts the document.
encrypt(String userPassword, String ownerPassword, int permissions, int cryptoAlgorithm) Encrypts the document.
encrypt(String userPassword, String ownerPassword, int permissions, int cryptoAlgorithm, boolean usePdf20) Encrypts the document.
changePasswords(String ownerPassword, String newUserPassword, String newOwnerPassword) Changes document passwords.
isLinearized() Gets a value indicating whether document is linearized.
setLinearized(boolean value) Sets a value indicating whether document is linearized.
decrypt() Decrypts the document.
getPermissions() Gets permissions of the document.
isEncrypted() Gets encrypted status of the document.
optimize() Linearize document in order to - open the first page as quickly as possible; - display next page or follow by link to the next page as quickly as possible; - display the page incrementally as it arrives when data for a page is delivered over a slow channel (display the most useful data first); - permit user interaction, such as following a link, to be performed even before the entire page has been received and displayed.
save() Save document incrementally (i.e. using incremental update technique).
save(String outputFileName, SaveFormat format) Saves the document with a new name along with a file format.
saveIncrementally(OutputStream output) Saves incrementally the PDF Document to the specified stream.
saveIncrementally(System.IO.Stream output) Saves incrementally the PDF Document to the specified stream.
saveIncrementally(String outputFileName) Saves incrementally the PDF Document to the specified stream.
save(OutputStream outputStream, SaveFormat format) Saves the document with a new name along with a file format.
save(String outputFileName, SaveOptions options) Saves the document with a new name setting its save options.
save(OutputStream outputStream, SaveOptions options) Saves the document to a stream with a save options.
getId() Gets the ID.
getMetadataStream() Returns raw metadata stream
suppressUpdate() Suppresses update contents data for all pages The contents is not updated until ResumeUpdate is called
resumeUpdate() resumes document update
dispose() Closes all resources used by this document.
close() Closes all resources used by this document.
getBackground() Gets the background color of the document.
setBackground(Color value) Sets the background color of the document.
getDefaultCopier() Returns copier used for coping pages to this document.
optimizeResources() Optimize resources in the document: 1.
optimizeResources(OptimizationOptions strategy) Optimize resources in the document according to defined optimization strategy.
getOptimizeSize() Gets optimization flag.
setOptimizeSize(boolean value) Sets optimization flag.
getIgnoreCorruptedObjects() Gets or sets flag of ignoring errors in source files.
setIgnoreCorruptedObjects(boolean value) Gets or sets flag of ignoring errors in source files.
getCatalogValue(String key) Returns item value from catalog dictionary.
getPageLabels() Gets page labels in the document.
freeMemory() Clears memory
isAbsentFontTryToSubstitute() Flag which informs about replacement of missing font.
setAbsentFontTryToSubstitute(boolean setAbsentFontTryToSubstitute) Setting flag for set program determined font in case of absense font.
check(boolean doRepair) Validates document.
isManualDisposeEnabled() By default method save close internal streams and release memory resources.
setManualDisposeEnabled(boolean manualDisposeEnabled) By default method save closes internal streams and release memory resources.
pageNodesToBalancedTree() Organizes page tree nodes in a document into a balanced tree.
pageNodesToBalancedTree(byte nodesNumInSubtrees) Organizes page tree nodes in a document into a balanced tree.

Document()

public Document()

Initializes empty document.

Document(byte[] input)

public Document(byte[] input)

Initialize new Document instance from the input byte array.

Parameters:

Parameter Type Description
input byte[] byte array with pdf document.

Document(InputStream input)

public Document(InputStream input)

Initialize new Document instance from the input stream.

Parameters:

Parameter Type Description
input java.io.InputStream Stream with pdf document.

Document(InputStream input, String password)

public Document(InputStream input, String password)

Initialize new Document instance from the input stream.

Parameters:

Parameter Type Description
input java.io.InputStream Input stream object, corresponding pdf is password protected.
password java.lang.String User or owner password.

Document(System.IO.Stream input)

public Document(System.IO.Stream input)

Initialize new Document instance from the input stream.

Parameters:

Parameter Type Description
input com.aspose.ms.System.IO.Stream Stream with pdf document.

Document(InputStream input, String password, boolean isManagedStream)

public Document(InputStream input, String password, boolean isManagedStream)

Initialize new Document instance from the input stream.

Parameters:

Parameter Type Description
input java.io.InputStream Stream with pdf document.
password java.lang.String User or owner password.
isManagedStream boolean if set to true inner stream is closed before exit; otherwise, is not.

Document(InputStream input, boolean isManagedStream)

public Document(InputStream input, boolean isManagedStream)

Initialize new Document instance from the input stream.

Parameters:

Parameter Type Description
input java.io.InputStream Stream with pdf document.
isManagedStream boolean if set to true inner stream is closed before exit; otherwise, is not.

Document(InputStream input, LoadOptions options)

public Document(InputStream input, LoadOptions options)

Opens an existing document from a stream providing necessary converting to get pdf document.

Parameters:

Parameter Type Description
input java.io.InputStream Input stream to convert into pdf document.
options LoadOptions Represents properties for converting input into pdf document.

Document(String filename, LoadOptions options)

public Document(String filename, LoadOptions options)

Opens an existing document from a file providing necessary converting to get pdf document.

Parameters:

Parameter Type Description
filename java.lang.String Input file to convert into pdf document.
options LoadOptions Represents properties for converting filename into pdf document.

Document(System.IO.Stream input, String password)

public Document(System.IO.Stream input, String password)

Opens an existing document from a stream.

Parameters:

Parameter Type Description
input com.aspose.ms.System.IO.Stream Input file to convert into pdf document.
password java.lang.String User or owner password.

Document(String filename)

public Document(String filename)

Just init Document using filename . The same as Document(Stream) .

Parameters:

Parameter Type Description
filename java.lang.String The name of the pdf document file.

Document(String filename, String password)

public Document(String filename, String password)

Initializes new instance of the Document class for working with encrypted document.

Parameters:

Parameter Type Description
filename java.lang.String Document file name.
password java.lang.String User or owner password.

Document(String filename, String password, boolean isManagedStream)

public Document(String filename, String password, boolean isManagedStream)

Initializes new instance of the Document class for working with encrypted document.

Parameters:

Parameter Type Description
filename java.lang.String Document file name.
password java.lang.String User or owner password.
isManagedStream boolean if set to true inner stream is closed before exit; otherwise, is not.

getPageInfo()

public PageInfo getPageInfo()

Gets the page info.(for generator only, not filled in when reading document)

Returns: PageInfo - The page info.

setPageInfo(PageInfo value)

public void setPageInfo(PageInfo value)

Sets the page info.(for generator only, not filled in when reading document)

Parameters:

Parameter Type Description
value PageInfo PageInfo object

getDestinations()

public DestinationCollection getDestinations()

Gets the collection of destinations.

Returns: DestinationCollection - DestinationCollection element

getPdfFormat()

public PdfFormat getPdfFormat()

Gets pdfa format

Returns: PdfFormat - PdfFormat element

getFontUtilities()

public Document.IDocumentFontUtilities getFontUtilities()

IDocumentFontUtilities instance

Returns: IDocumentFontUtilities - IDocumentFontUtilities instance

removePdfaCompliance()

public void removePdfaCompliance()

Remove pdfa compliance from the document

getCollection()

public Collection getCollection()

Gets collection of document.

Returns: Collection - Collection object

setCollection(Collection value)

public void setCollection(Collection value)

Sets collection of document.

Parameters:

Parameter Type Description
value Collection Collection object

getEngineDoc()

public IPdfDocument getEngineDoc()

Instance of IPdfDocument used to access to internal document structure. Internal only

Returns: IPdfDocument - IPdfDocument object

getVersion()

public String getVersion()

Gets a version of Pdf from Pdf file header.

Returns: java.lang.String - String value

getOpenAction()

public IAppointment getOpenAction()

Gets action performed at document opening.


Example demonstrates how to get CenterWindow flag:

 Document document = new Document("sample.pdf");
 IAppointment value = document.getOpenAction();

Returns: IAppointment - IAppointment object

setOpenAction(IAppointment value)

public void setOpenAction(IAppointment value)

Sets action performed at document opening.

Parameters:

Parameter Type Description
value IAppointment IAppointment value

isHideToolBar()

public boolean isHideToolBar()

Gets flag specifying whether toolbar should be hidden when document is active.

Returns: boolean - boolean value


Example demonstrates how to get HideToolBar flag:

 Document document = new Document("sample.pdf");
 boolean value = document.isHideToolBar();

setHideToolBar(boolean value)

public void setHideToolBar(boolean value)

Set flag specifying whether toolbar should be hidden when document is active.

Parameters:

Parameter Type Description
value boolean boolean value

isHideMenubar()

public boolean isHideMenubar()

Gets flag specifying whether menu bar should be hidden when document is active.

Returns: boolean - boolean value


Example demonstrates how to get HideMenubar flag:

 Document document = new Document("sample.pdf");
 boolean value = document.isHideMenubar();

setHideMenubar(boolean value)

public void setHideMenubar(boolean value)

Sets flag specifying whether menu bar should be hidden when document is active.

Parameters:

Parameter Type Description
value boolean boolean value

isHideWindowUI()

public boolean isHideWindowUI()

Gets flag specifying whether user interface elements should be hidden when document is active.

Returns: boolean - boolean value


Example demonstrates how to get HideWindowUI flag:

 Document document = new Document("sample.pdf");
 boolean value = document.isHideWindowUI();

setHideWindowUI(boolean value)

public void setHideWindowUI(boolean value)

Sets flag specifying whether user interface elements should be hidden when document is active.

Parameters:

Parameter Type Description
value boolean boolean value

isFitWindow()

public boolean isFitWindow()

Gets flag specifying whether document window must be resized to fit the first displayed page.

Returns: boolean - boolean value


Example demonstrates how to get FitWindow flag:

 Document document = new Document("sample.pdf");
 boolean value = document.isFitWindow();

setFitWindow(boolean value)

public void setFitWindow(boolean value)

Sets flag specifying whether document window must be resized to fit the first displayed page.

Parameters:

Parameter Type Description
value boolean boolean value

isCenterWindow()

public boolean isCenterWindow()

Gets flag specifying whether position of the document’s window will be centered on the screen.

Returns: boolean - boolean value


Example demonstrates how to get CenterWindow flag:

 Document document = new Document("sample.pdf");
 boolean value = document.isCenterWindow();

setCenterWindow(boolean value)

public void setCenterWindow(boolean value)

Sets flag specifying whether position of the document’s window will be centered on the screen.

Parameters:

Parameter Type Description
value boolean boolean value

isDisplayDocTitle()

public boolean isDisplayDocTitle()

Gets flag specifying whether document’s window title bar should display document title.

Returns: boolean - boolean value


Example demonstrates how to get DisplayDocTitle flag:

 Document document = new Document("sample.pdf");
 boolean value = document.isDisplayDocTitle();

setDisplayDocTitle(boolean value)

public void setDisplayDocTitle(boolean value)

Sets flag specifying whether document’s window title bar should display document title.

Parameters:

Parameter Type Description
value boolean boolean value

getPages()

public PageCollection getPages()

Gets collection of document pages. Note that pages are numbered from 1 in collection.

Returns: PageCollection - PageCollection object


Example below demonstrates how to operate with the document pages:
 How to obtain number of pages and how to obtain rectangle of starting page of the document.

 Document document = new Document("sample.pdf");
 PageCollection  pages = document.getPages();
 System.out.println("Document contains " + pages.size());
 Page page = pages.get_Item(1);
 Rectangle rect = page.getRect();

getOutlines()

public OutlineCollection getOutlines()

Gets document outlines.

Returns: OutlineCollection - OutlineCollection object

getActions()

public DocumentActionCollection getActions()

Gets document actions. This property is instance of DocumentActions class which allows to get/set BeforClosing, BeforSaving, etc. actions.

Returns: DocumentActionCollection - DocumentActionCollection object


This example demonstrates how to obtain after open action of the document:

 Document document = new Document("PdfWithOpenAction.pdf");
 DocumentActionCollection actions = document.getActions();
 PdfAction afterSavingAction = actions.getAfterSaving();

getForm()

public Form getForm()

Gets Acro Form of the document.

Returns: Form - Form object

getEmbeddedFiles()

public EmbeddedFileCollection getEmbeddedFiles()

Gets collection of files embedded to document.

Returns: EmbeddedFileCollection - EmbeddedFileCollection object

getDirection()

public int getDirection()

Gets reading order of text: L2R (left to right) or R2L (right to left).

Returns: int - Direction element

setDirection(int value)

public void setDirection(int value)

Sets reading order of text: L2R (left to right) or R2L (right to left).

Parameters:

Parameter Type Description
value int int value

getPageMode()

public int getPageMode()

Gets page mode, specifying how document should be displayed when opened.

Returns: int - PageMode element

setPageMode(int pageMode)

public void setPageMode(int pageMode)

Sets page mode, specifying how document should be displayed when opened.

Parameters:

Parameter Type Description
pageMode int int value

getNonFullScreenPageMode()

public int getNonFullScreenPageMode()

Gets page mode, specifying how to display the document on exiting full-screen mode.

Returns: int - PageMode element

setNonFullScreenPageMode(int value)

public void setNonFullScreenPageMode(int value)

Sets page mode, specifying how to display the document on exiting full-screen mode.

Parameters:

Parameter Type Description
value int int value

getPageLayout()

public int getPageLayout()

Gets page layout which shall be used when the document is opened.

Returns: int - PageLayout element

setPageLayout(int value)

public void setPageLayout(int value)

Sets page layout which shall be used when the document is opened.

Parameters:

Parameter Type Description
value int int value

getFileName()

public String getFileName()

Name of the PDF file that caused this document

Returns: java.lang.String - String object

getInfo()

public DocumentInfo getInfo()

Gets document info.

Returns: DocumentInfo - DocumentInfo object

getMetadata()

public Metadata getMetadata()

Document metadata. (A PDF document may include general information, such as the document’s title, author, and creation and modification dates. Such global information about the document (as opposed to its content or structure) is called metadata and is intended to assist in cataloguing and searching for documents in external databases.)

Returns: Metadata - Metadata object

getLogicalStructure()

public RootElement getLogicalStructure()

Gets logical structure of the document.

Returns: RootElement - RootElement object

processParagraphs()

public void processParagraphs()

Stores document into stream.

save(System.IO.Stream output)

public void save(System.IO.Stream output)

Stores document into stream.

Parameters:

Parameter Type Description
output com.aspose.ms.System.IO.Stream Stream where document shell be stored.

save(OutputStream output)

public void save(OutputStream output)

Stores document into stream.

Parameters:

Parameter Type Description
output java.io.OutputStream Stream where document shell be stored.

save(String outputFileName)

public void save(String outputFileName)

Saves document into the specified file.

Parameters:

Parameter Type Description
outputFileName java.lang.String Path to file where the document will be stored.

exportAnnotationsToXfdf(String fileName)

public void exportAnnotationsToXfdf(String fileName)

Exports all document annotations to XFDF file

Parameters:

Parameter Type Description
fileName java.lang.String XFDF file name

sendTo(DocumentDevice device, OutputStream output)

public void sendTo(DocumentDevice device, OutputStream output)

Sends the whole document to the document device for processing.

Parameters:

Parameter Type Description
device DocumentDevice Document device which is used to process the document.
output java.io.OutputStream Output stream contains the results of the document processing with given device.

sendTo(DocumentDevice device, int fromPage, int toPage, OutputStream output)

public void sendTo(DocumentDevice device, int fromPage, int toPage, OutputStream output)

Sends the certain pages of the document to the document device for processing.

Parameters:

Parameter Type Description
device DocumentDevice Document device which is used to process the document.
fromPage int The first page for processing.
toPage int The last page for processing.
output java.io.OutputStream Output stream contains the results of the document pages processing with given device.

sendTo(DocumentDevice device, String outputFileName)

public void sendTo(DocumentDevice device, String outputFileName)

Sends the whole document to the document device for processing.

Parameters:

Parameter Type Description
device DocumentDevice Document device which is used to process the document.
outputFileName java.lang.String Output file name with the results of processing.

sendTo(DocumentDevice device, int fromPage, int toPage, String outputFileName)

public void sendTo(DocumentDevice device, int fromPage, int toPage, String outputFileName)

Sends the whole document to the document device for processing.

Parameters:

Parameter Type Description
device DocumentDevice Document device which is used to process the document.
fromPage int The first page for processing.
toPage int The last page for processing.
outputFileName java.lang.String Output file name with the results of processing.

removeMetadata()

public void removeMetadata()

Removes metadata from the document.

importAnnotationsFromXfdf(String fileName)

public void importAnnotationsFromXfdf(String fileName)

Imports annotations from XFDF file to document.

Parameters:

Parameter Type Description
fileName java.lang.String XFDF file name

validate(String outputLogFileName, PdfFormat format)

public boolean validate(String outputLogFileName, PdfFormat format)

Validate document into the specified file.

Parameters:

Parameter Type Description
outputLogFileName java.lang.String Path to file where the comments will be stored.
format PdfFormat PdfFormat element.

Returns: boolean

convert(String outputLogFileName, PdfFormat format, int action)

public boolean convert(String outputLogFileName, PdfFormat format, int action)

Convert document and save errors into the specified file.

Parameters:

Parameter Type Description
outputLogFileName java.lang.String Path to file where the comments will be stored.
format PdfFormat Pdf format.
action int Action for objects that can not be converted

Returns: boolean - boolean value

validate(OutputStream outputLogStream, PdfFormat format)

public boolean validate(OutputStream outputLogStream, PdfFormat format)

Validate document into the specified file.

Parameters:

Parameter Type Description
outputLogStream java.io.OutputStream Stream where the comments will be stored.
format PdfFormat Pdf format.

Returns: boolean - boolean value

convert(String outputLogFileName, PdfFormat format, int action, int transparencyAction)

public boolean convert(String outputLogFileName, PdfFormat format, int action, int transparencyAction)

Convert document and save errors into the specified file.

Parameters:

Parameter Type Description
outputLogFileName java.lang.String Path to file where the comments will be stored.
format PdfFormat The pdf format.
action int Action for objects that can not be converted
transparencyAction int Action for image masked objects

Returns: boolean - The operation result

convert(Document.CallBackGetHocr callback)

public boolean convert(Document.CallBackGetHocr callback)

Convert document to searchable document.

Parameters:

Parameter Type Description
callback CallBackGetHocr The call back procedure for hocr recognize.

Returns: boolean - boolean value

convertWithSkippingErrors(Document.CallBackGetHocr callback)

public boolean convertWithSkippingErrors(Document.CallBackGetHocr callback)

Convert document to searchable document and skip errors of hochr that can not be converted.

Parameters:

Parameter Type Description
callback CallBackGetHocr The call back procedure for hocr recognize.

Returns: boolean - boolean value

convertInternal(System.IO.Stream outputLogStream, PdfFormat format, int action)

public boolean convertInternal(System.IO.Stream outputLogStream, PdfFormat format, int action)

Convert document and save errors into the specified stream.

Parameters:

Parameter Type Description
outputLogStream com.aspose.ms.System.IO.Stream Stream where the comments will be stored.
format PdfFormat Pdf format.
action int The call back procedure for hocr recognize.

Returns: boolean - boolean value

convert(OutputStream outputLogStream, PdfFormat format, int action)

public boolean convert(OutputStream outputLogStream, PdfFormat format, int action)

Convert document and save errors into the specified stream.

Parameters:

Parameter Type Description
outputLogStream java.io.OutputStream Stream where the comments will be stored.
format PdfFormat Pdf format.
action int Action for objects that can not be converted

Returns: boolean - boolean value

convert(PdfFormatConversionOptions options)

public boolean convert(PdfFormatConversionOptions options)

Convert document using specified conversion options

Parameters:

Parameter Type Description
options PdfFormatConversionOptions set of options for convert PDF document

Returns: boolean - The operation result

convert(int fixup, OutputStream outputLog)

public final boolean convert(int fixup, OutputStream outputLog)

Convert document by applying the Fixup.

Parameters:

Parameter Type Description
fixup int The Fixup type.
outputLog java.io.OutputStream The log of process.

Returns: boolean - The operation result.

convert(int fixup, OutputStream outputLog, boolean onlyValidation, Object[] parameters)

public final boolean convert(int fixup, OutputStream outputLog, boolean onlyValidation, Object[] parameters)

Convert document by applying the Fixup.

Parameters:

Parameter Type Description
fixup int The Fixup type.
outputLog java.io.OutputStream The log of process.
onlyValidation boolean Only document validation.
parameters java.lang.Object[] Properties for Fixup that can not be set.

Returns: boolean - The operation result.

convert(int fixup, String outputLog)

public boolean convert(int fixup, String outputLog)

Convert document by applying the Fixup.

Parameters:

Parameter Type Description
fixup int The Fixup type.
outputLog java.lang.String The log of process.

Returns: boolean - The operation result.

convert(int fixup, String outputLog, boolean onlyValidation, Object[] parameters)

public boolean convert(int fixup, String outputLog, boolean onlyValidation, Object[] parameters)

Convert document by applying the Fixup.

Parameters:

Parameter Type Description
fixup int The Fixup type.
outputLog java.lang.String The log of process.
onlyValidation boolean Only document validation.
parameters java.lang.Object[] Properties for Fixup that can not be set.

Returns: boolean - The operation result.

flatten()

public void flatten()

Removes all fields from the document and place their values instead.

getCryptoAlgorithm()

public int getCryptoAlgorithm()

Gets security settings if document is encrypted. If document is not encrypted then corresponding exception will be raised in .net 1.1 or CryptoAlgorithm will be null for other .net versions.

Returns: int - CryptoAlgorithm element

encrypt(String userPassword, String ownerPassword, DocumentPrivilege privileges, int cryptoAlgorithm, boolean usePdf20)

public void encrypt(String userPassword, String ownerPassword, DocumentPrivilege privileges, int cryptoAlgorithm, boolean usePdf20)

Encrypts the document. Call then Save to get encrypted version of the document.

Parameters:

Parameter Type Description
userPassword java.lang.String User password.
ownerPassword java.lang.String Owner password.
privileges DocumentPrivilege Document permissions, see Permissions for details.
cryptoAlgorithm int Cryptographic algorithm, see CryptoAlgorithm for details.
usePdf20 boolean Support for revision 6 (Extension 8).

encrypt(String userPassword, String ownerPassword, int permissions, int cryptoAlgorithm)

public void encrypt(String userPassword, String ownerPassword, int permissions, int cryptoAlgorithm)

Encrypts the document. Call then Save to get encrypted version of the document.

Parameters:

Parameter Type Description
userPassword java.lang.String User password.
ownerPassword java.lang.String Owner password.
permissions int Document permissions, see Permissions for details.
cryptoAlgorithm int Cryptographic algorithm, see CryptoAlgorithm for details.

encrypt(String userPassword, String ownerPassword, int permissions, int cryptoAlgorithm, boolean usePdf20)

public void encrypt(String userPassword, String ownerPassword, int permissions, int cryptoAlgorithm, boolean usePdf20)

Encrypts the document. Call then Save to get encrypted version of the document.

Parameters:

Parameter Type Description
userPassword java.lang.String User password.
ownerPassword java.lang.String Owner password.
permissions int Document permissions, see Permissions for details.
cryptoAlgorithm int Cryptographic algorithm, see CryptoAlgorithm for details.
usePdf20 boolean Support for revision 6 (Extension 8).

changePasswords(String ownerPassword, String newUserPassword, String newOwnerPassword)

public void changePasswords(String ownerPassword, String newUserPassword, String newOwnerPassword)

Changes document passwords. This action can be done only using owner password.

Parameters:

Parameter Type Description
ownerPassword java.lang.String Owner password.
newUserPassword java.lang.String New user password.
newOwnerPassword java.lang.String New owner password.

isLinearized()

public boolean isLinearized()

Gets a value indicating whether document is linearized.

Returns: boolean - boolean value

setLinearized(boolean value)

public void setLinearized(boolean value)

Sets a value indicating whether document is linearized.

Parameters:

Parameter Type Description
value boolean boolean value

decrypt()

public void decrypt()

Decrypts the document. Call then Save to obtain decrypted version of the document.

getPermissions()

public int getPermissions()

Gets permissions of the document.

Returns: int - int value

isEncrypted()

public boolean isEncrypted()

Gets encrypted status of the document. True if document is encrypted.

Returns: boolean - boolean value

optimize()

public void optimize()

Linearize document in order to - open the first page as quickly as possible; - display next page or follow by link to the next page as quickly as possible; - display the page incrementally as it arrives when data for a page is delivered over a slow channel (display the most useful data first); - permit user interaction, such as following a link, to be performed even before the entire page has been received and displayed. Invoking this method doesn’t actually saves the document. On the contrary the document only is prepared to have optimized structure, call then Save to get optimized document.

save()

public void save()

Save document incrementally (i.e. using incremental update technique).


In order to save document incrementally we should open the document file for writing. Therefore Document must not be initialized with InputStream but with path to the file, like in the next code snippet: Document doc = new Document(“document.pdf”); // make some changes and save the document incrementally doc.save();

In case when document was initialized with InputStream, writing to InputStream is impossible, so we recommend to use separate methods “save” to save document or “saveIncrementally” to save document incrementally.

save(String outputFileName, SaveFormat format)

public void save(String outputFileName, SaveFormat format)

Saves the document with a new name along with a file format.

Parameters:

Parameter Type Description
outputFileName java.lang.String Path to file where the document will be stored.
format SaveFormat Format options.

saveIncrementally(OutputStream output)

public void saveIncrementally(OutputStream output)

Saves incrementally the PDF Document to the specified stream.

Parameters:

Parameter Type Description
output java.io.OutputStream OutputStream object

saveIncrementally(System.IO.Stream output)

public void saveIncrementally(System.IO.Stream output)

Saves incrementally the PDF Document to the specified stream.

Parameters:

Parameter Type Description
output com.aspose.ms.System.IO.Stream OutputStream object

saveIncrementally(String outputFileName)

public void saveIncrementally(String outputFileName)

Saves incrementally the PDF Document to the specified stream.

Parameters:

Parameter Type Description
outputFileName java.lang.String OutputStream object

save(OutputStream outputStream, SaveFormat format)

public void save(OutputStream outputStream, SaveFormat format)

Saves the document with a new name along with a file format.

Parameters:

Parameter Type Description
outputStream java.io.OutputStream Stream where the document will be stored.
format SaveFormat Format options.

save(String outputFileName, SaveOptions options)

public void save(String outputFileName, SaveOptions options)

Saves the document with a new name setting its save options.

Parameters:

Parameter Type Description
outputFileName java.lang.String Path to file where the document will be stored.
options SaveOptions Save options.

save(OutputStream outputStream, SaveOptions options)

public void save(OutputStream outputStream, SaveOptions options)

Saves the document to a stream with a save options.

Parameters:

Parameter Type Description
outputStream java.io.OutputStream Stream where the document will be stored.
options SaveOptions Save options.

getId()

public Id getId()

Gets the ID.

Returns: Id - Id object

getMetadataStream()

public IPdfStreamAccessor getMetadataStream()

Returns raw metadata stream

Returns: IPdfStreamAccessor - IPdfStreamAccessor object

suppressUpdate()

public void suppressUpdate()

Suppresses update contents data for all pages The contents is not updated until ResumeUpdate is called

resumeUpdate()

public void resumeUpdate()

resumes document update

dispose()

public void dispose()

Closes all resources used by this document.

This method is obsolete, use close() instead.

close()

public void close()

Closes all resources used by this document.

getBackground()

public Color getBackground()

Gets the background color of the document.

Returns: Color - Color object

setBackground(Color value)

public void setBackground(Color value)

Sets the background color of the document.

Parameters:

Parameter Type Description
value java.awt.Color Color object

getDefaultCopier()

public Copier getDefaultCopier()

Returns copier used for coping pages to this document.

Returns: Copier - Copier object

optimizeResources()

public void optimizeResources()

Optimize resources in the document: 1. Resources which are not used on the document pages are removed; 2. Equal resources are joined into one object; 3. Unused objects are deleted.

optimizeResources(OptimizationOptions strategy)

public void optimizeResources(OptimizationOptions strategy)

Optimize resources in the document according to defined optimization strategy.

Parameters:

Parameter Type Description
strategy OptimizationOptions Optimization strategy.

getOptimizeSize()

public boolean getOptimizeSize()

Gets optimization flag. When pages are added to document, equal resource streams in resultant file are merged into one PDF object if this flag set. This allows to decrease resultant file size but may cause slower execution and larger memory requirements. Default value: false.

Returns: boolean - boolean value

setOptimizeSize(boolean value)

public void setOptimizeSize(boolean value)

Sets optimization flag. When pages are added to document, equal resource streams in resultant file are merged into one PDF object if this flag set. This allows to decrease resultant file size but may cause slower execution and larger memory requirements. Default value: false.

Parameters:

Parameter Type Description
value boolean boolean value

getIgnoreCorruptedObjects()

public boolean getIgnoreCorruptedObjects()

Gets or sets flag of ignoring errors in source files. When pages from source document copied into destination document, copying process is stopped with exception if some objects in source files are corrupted when this flag is false. example: dest.Pages.Add(src.Pages); If this flag is set to true then corrupted objects will be replaced with empty values. By default: true.

Returns: boolean - boolean value

setIgnoreCorruptedObjects(boolean value)

public void setIgnoreCorruptedObjects(boolean value)

Gets or sets flag of ignoring errors in source files. When pages from source document copied into destination document, copying process is stopped with exception if some objects in source files are corrupted when this flag is false. example: dest.Pages.Add(src.Pages); If this flag is set to true then corrupted objects will be replaced with empty values. By default: true.

Parameters:

Parameter Type Description
value boolean boolean value

getCatalogValue(String key)

public Object getCatalogValue(String key)

Returns item value from catalog dictionary.

Parameters:

Parameter Type Description
key java.lang.String The key of item.

Returns: java.lang.Object - Item value - if key was successfully found; otherwise, null.

getPageLabels()

public PageLabelCollection getPageLabels()

Gets page labels in the document.

Returns: PageLabelCollection - PageLabelCollection object

freeMemory()

public void freeMemory()

Clears memory

isAbsentFontTryToSubstitute()

public boolean isAbsentFontTryToSubstitute()

Flag which informs about replacement of missing font.

Returns: boolean

setAbsentFontTryToSubstitute(boolean setAbsentFontTryToSubstitute)

public void setAbsentFontTryToSubstitute(boolean setAbsentFontTryToSubstitute)

Setting flag for set program determined font in case of absense font.

Parameters:

Parameter Type Description
setAbsentFontTryToSubstitute boolean

check(boolean doRepair)

public boolean check(boolean doRepair)

Validates document.

Parameters:

Parameter Type Description
doRepair boolean If true found issues will be repaired.

Returns: boolean - boolean value

isManualDisposeEnabled()

public boolean isManualDisposeEnabled()

By default method save close internal streams and release memory resources. We can do some operations and continue work with the document after method save if this ManualDispose parameter is enabled.

Returns: boolean - boolean value. (Default value == false)

setManualDisposeEnabled(boolean manualDisposeEnabled)

public void setManualDisposeEnabled(boolean manualDisposeEnabled)

By default method save closes internal streams and release memory resources. We can do some operations and continue work with the document after method save is called if this ManualDispose parameter is enabled. But it is strongly recommended to call the dispose method when the Document instance is no longer needed.

Parameters:

Parameter Type Description
manualDisposeEnabled boolean boolean value. (Default value == false)

pageNodesToBalancedTree()

public final void pageNodesToBalancedTree()

Organizes page tree nodes in a document into a balanced tree. Only if the document has more than nodesNumInSubtrees page objects, otherwise it does nothing.

pageNodesToBalancedTree(byte nodesNumInSubtrees)

public final void pageNodesToBalancedTree(byte nodesNumInSubtrees)

Organizes page tree nodes in a document into a balanced tree. Only if the document has more than nodesNumInSubtrees page objects, otherwise it does nothing.

Parameters:

Parameter Type Description
nodesNumInSubtrees byte Desired number of subnodes.