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

ConstructorDescription
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

MethodDescription
getPageInfo()Gets the page info.(for generator only, not filled in when reading document)
setPageInfo(PageInfo value)Sets the page info.(for generator only, not filled in when reading document)
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)Recognize images inside the document and add hocr strings over it.
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 (and annotations) from the document and place their values instead.
flattenTransparency()Replaces transparent content with non-transparent raster and vector graphics.
getCryptoAlgorithm()Gets security settings if document is encrypted.
encrypt(String userPassword, String ownerPassword, DocumentPrivilege privileges, CryptoAlgorithm cryptoAlgorithm, boolean usePdf20)Encrypts the document.
encrypt(String userPassword, String ownerPassword, int permissions, CryptoAlgorithm cryptoAlgorithm)Encrypts the document.
encrypt(String userPassword, String ownerPassword, int permissions, CryptoAlgorithm 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.
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:

ParameterTypeDescription
inputbyte[]byte array with pdf document.

Document(InputStream input)

public Document(InputStream input)

Initialize new Document instance from the input stream.

Parameters:

ParameterTypeDescription
inputjava.io.InputStreamStream with pdf document.

Document(InputStream input, String password)

public Document(InputStream input, String password)

Initialize new Document instance from the input stream.

Parameters:

ParameterTypeDescription
inputjava.io.InputStreamInput stream object, corresponding pdf is password protected.
passwordjava.lang.StringUser or owner password.

Document(System.IO.Stream input)

public Document(System.IO.Stream input)

Initialize new Document instance from the input stream.

Parameters:

ParameterTypeDescription
inputcom.aspose.ms.System.IO.StreamStream 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:

ParameterTypeDescription
inputjava.io.InputStreamStream with pdf document.
passwordjava.lang.StringUser or owner password.
isManagedStreambooleanif 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:

ParameterTypeDescription
inputjava.io.InputStreamStream with pdf document.
isManagedStreambooleanif 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:

ParameterTypeDescription
inputjava.io.InputStreamInput stream to convert into pdf document.
optionsLoadOptionsRepresents 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:

ParameterTypeDescription
filenamejava.lang.StringInput file to convert into pdf document.
optionsLoadOptionsRepresents 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:

ParameterTypeDescription
inputcom.aspose.ms.System.IO.StreamInput file to convert into pdf document.
passwordjava.lang.StringUser or owner password.

Document(String filename)

public Document(String filename)

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

Parameters:

ParameterTypeDescription
filenamejava.lang.StringThe 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:

ParameterTypeDescription
filenamejava.lang.StringDocument file name.
passwordjava.lang.StringUser 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:

ParameterTypeDescription
filenamejava.lang.StringDocument file name.
passwordjava.lang.StringUser or owner password.
isManagedStreambooleanif 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:

ParameterTypeDescription
valuePageInfoPageInfo 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:

ParameterTypeDescription
valueCollectionCollection 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:

ParameterTypeDescription
valueIAppointmentIAppointment 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:

ParameterTypeDescription
valuebooleanboolean 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:

ParameterTypeDescription
valuebooleanboolean 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:

ParameterTypeDescription
valuebooleanboolean 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:

ParameterTypeDescription
valuebooleanboolean 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:

ParameterTypeDescription
valuebooleanboolean 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:

ParameterTypeDescription
valuebooleanboolean 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:

ParameterTypeDescription
valueintint 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:

ParameterTypeDescription
pageModeintint 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:

ParameterTypeDescription
valueintint 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:

ParameterTypeDescription
valueintint 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:

ParameterTypeDescription
outputcom.aspose.ms.System.IO.StreamStream where document shell be stored.

save(OutputStream output)

public void save(OutputStream output)

Stores document into stream.

Parameters:

ParameterTypeDescription
outputjava.io.OutputStreamStream where document shell be stored.

save(String outputFileName)

public void save(String outputFileName)

Saves document into the specified file.

Parameters:

ParameterTypeDescription
outputFileNamejava.lang.StringPath to file where the document will be stored.

exportAnnotationsToXfdf(String fileName)

public void exportAnnotationsToXfdf(String fileName)

Exports all document annotations to XFDF file

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringXFDF 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:

ParameterTypeDescription
deviceDocumentDeviceDocument device which is used to process the document.
outputjava.io.OutputStreamOutput 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:

ParameterTypeDescription
deviceDocumentDeviceDocument device which is used to process the document.
fromPageintThe first page for processing.
toPageintThe last page for processing.
outputjava.io.OutputStreamOutput 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:

ParameterTypeDescription
deviceDocumentDeviceDocument device which is used to process the document.
outputFileNamejava.lang.StringOutput 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:

ParameterTypeDescription
deviceDocumentDeviceDocument device which is used to process the document.
fromPageintThe first page for processing.
toPageintThe last page for processing.
outputFileNamejava.lang.StringOutput 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:

ParameterTypeDescription
fileNamejava.lang.StringXFDF file name

validate(String outputLogFileName, PdfFormat format)

public boolean validate(String outputLogFileName, PdfFormat format)

Validate document into the specified file.

Parameters:

ParameterTypeDescription
outputLogFileNamejava.lang.StringPath to file where the comments will be stored.
formatPdfFormatPdfFormat 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:

ParameterTypeDescription
outputLogFileNamejava.lang.StringPath to file where the comments will be stored.
formatPdfFormatPdf format.
actionintAction 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:

ParameterTypeDescription
outputLogStreamjava.io.OutputStreamStream where the comments will be stored.
formatPdfFormatPdf 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:

ParameterTypeDescription
outputLogFileNamejava.lang.StringPath to file where the comments will be stored.
formatPdfFormatThe pdf format.
actionintAction for objects that can not be converted
transparencyActionintAction for image masked objects

Returns: boolean - The operation result

convert(Document.CallBackGetHocr callback)

public boolean convert(Document.CallBackGetHocr callback)

Recognize images inside the document and add hocr strings over it.

Parameters:

ParameterTypeDescription
callbackCallBackGetHocrcallback Action for images that will be processed by hocr recognize.

Returns: boolean - boolean value The operation result. If there are no images in the document returns false .

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:

ParameterTypeDescription
callbackCallBackGetHocrThe 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:

ParameterTypeDescription
outputLogStreamcom.aspose.ms.System.IO.StreamStream where the comments will be stored.
formatPdfFormatPdf format.
actionintThe 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:

ParameterTypeDescription
outputLogStreamjava.io.OutputStreamStream where the comments will be stored.
formatPdfFormatPdf format.
actionintAction 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:

ParameterTypeDescription
optionsPdfFormatConversionOptionsset 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:

ParameterTypeDescription
fixupintThe Fixup type.
outputLogjava.io.OutputStreamThe 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:

ParameterTypeDescription
fixupintThe Fixup type.
outputLogjava.io.OutputStreamThe log of process.
onlyValidationbooleanOnly document validation.
parametersjava.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:

ParameterTypeDescription
fixupintThe Fixup type.
outputLogjava.lang.StringThe 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:

ParameterTypeDescription
fixupintThe Fixup type.
outputLogjava.lang.StringThe log of process.
onlyValidationbooleanOnly document validation.
parametersjava.lang.Object[]Properties for Fixup that can not be set.

Returns: boolean - The operation result.

flatten()

public void flatten()

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

flattenTransparency()

public final void flattenTransparency()

Replaces transparent content with non-transparent raster and vector graphics.

getCryptoAlgorithm()

public CryptoAlgorithm 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: CryptoAlgorithm - CryptoAlgorithm element

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

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

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

Parameters:

ParameterTypeDescription
userPasswordjava.lang.StringUser password.
ownerPasswordjava.lang.StringOwner password.
privilegesDocumentPrivilegeDocument permissions, see Permissions for details.
cryptoAlgorithmCryptoAlgorithmCryptographic algorithm, see CryptoAlgorithm for details.
usePdf20booleanSupport for revision 6 (Extension 8).

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

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

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

Parameters:

ParameterTypeDescription
userPasswordjava.lang.StringUser password.
ownerPasswordjava.lang.StringOwner password.
permissionsintDocument permissions, see Permissions for details.
cryptoAlgorithmCryptoAlgorithmCryptographic algorithm, see CryptoAlgorithm for details.

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

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

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

Parameters:

ParameterTypeDescription
userPasswordjava.lang.StringUser password.
ownerPasswordjava.lang.StringOwner password.
permissionsintDocument permissions, see Permissions for details.
cryptoAlgorithmCryptoAlgorithmCryptographic algorithm, see CryptoAlgorithm for details.
usePdf20booleanSupport 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:

ParameterTypeDescription
ownerPasswordjava.lang.StringOwner password.
newUserPasswordjava.lang.StringNew user password.
newOwnerPasswordjava.lang.StringNew 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:

ParameterTypeDescription
valuebooleanboolean 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:

ParameterTypeDescription
outputFileNamejava.lang.StringPath to file where the document will be stored.
formatSaveFormatFormat options.

saveIncrementally(OutputStream output)

public void saveIncrementally(OutputStream output)

Saves incrementally the PDF Document to the specified stream.

Parameters:

ParameterTypeDescription
outputjava.io.OutputStreamOutputStream object

saveIncrementally(System.IO.Stream output)

public void saveIncrementally(System.IO.Stream output)

Saves incrementally the PDF Document to the specified stream.

Parameters:

ParameterTypeDescription
outputcom.aspose.ms.System.IO.StreamOutputStream object

saveIncrementally(String outputFileName)

public void saveIncrementally(String outputFileName)

Saves incrementally the PDF Document to the specified stream.

Parameters:

ParameterTypeDescription
outputFileNamejava.lang.StringOutputStream 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:

ParameterTypeDescription
outputStreamjava.io.OutputStreamStream where the document will be stored.
formatSaveFormatFormat 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:

ParameterTypeDescription
outputFileNamejava.lang.StringPath to file where the document will be stored.
optionsSaveOptionsSave options.

save(OutputStream outputStream, SaveOptions options)

public void save(OutputStream outputStream, SaveOptions options)

Saves the document to a stream with a save options.

Parameters:

ParameterTypeDescription
outputStreamjava.io.OutputStreamStream where the document will be stored.
optionsSaveOptionsSave 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:

ParameterTypeDescription
valuejava.awt.ColorColor 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:

ParameterTypeDescription
strategyOptimizationOptionsOptimization 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:

ParameterTypeDescription
valuebooleanboolean 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:

ParameterTypeDescription
valuebooleanboolean value

getCatalogValue(String key)

public Object getCatalogValue(String key)

Returns item value from catalog dictionary.

Parameters:

ParameterTypeDescription
keyjava.lang.StringThe 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:

ParameterTypeDescription
setAbsentFontTryToSubstituteboolean

check(boolean doRepair)

public boolean check(boolean doRepair)

Validates document.

Parameters:

ParameterTypeDescription
doRepairbooleanIf 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:

ParameterTypeDescription
manualDisposeEnabledbooleanboolean value. (Default value == false)

pageNodesToBalancedTree()

public 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 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:

ParameterTypeDescription
nodesNumInSubtreesbyteDesired number of subnodes.