IDocument

All Implemented Interfaces: com.aspose.ms.System.IDisposable, java.io.Closeable

public interface IDocument extends System.IDisposable, Closeable

interface representing PDF document

Methods

MethodDescription
isPdfaCompliant()
isPdfUaCompliant()Gets the is document pdfua compliant.
getDestinations()Gets the collection of destinations.
getPdfFormat()
isDisableFontLicenseVerifications()Many operations with font can’t be executed if these operations are prohibited by license of this font.
setDisableFontLicenseVerifications(boolean value)Many operations with font can’t be executed if these operations are prohibited by license of this font.
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.
getOptimizeSize()Gets optimization flag.
setOptimizeSize(boolean value)Sets optimization flag.
getIgnoreCorruptedObjects()Gets or sets flag of ignoring errors in source files.
setIgnoreCorruptedObjects(boolean value)
getCatalogValue(String key)Returns item value from catalog dictionary.
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 or sets 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 centerd on the screen.
setCenterWindow(boolean value)Sets flag specifying whether position of the document’s window will be centerd 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 value)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.
getDuplex()Gets or sets print duplex mode handling option to use when printing the file from the print dialog.
setDuplex(int value)Gets or sets print duplex mode handling option to use when printing the file from the print dialog.
getPrintScaling()Gets print scaling handling option to use when printing the file from the print dialog.
setPrintScaling(int value)Sets print scaling handling option to use when printing the file from the print dialog.
getFileName()Name of the PDF file that caused this document
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)
getEnableSignatureSanitization()Gets or sets flag to manage signature fields sanitization.
setEnableSignatureSanitization(boolean value)Gets or sets flag to manage signature fields sanitization.
getInfo()Gets document info.
getMetadata()Document metadata.
getLogicalStructure()Gets logical structure of the document.
processParagraphs()Stores document into stream.
save(OutputStream output)Stores document into stream.
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.
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.
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(String outputLogFileName, PdfFormat format, int action)Convert document and save errors into the specified file.
convert(PdfFormatConversionOptions options)Convert document using specified conversion options
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.
convert(Document.CallBackGetHocr callback, boolean isTestVisible)Convert document and save errors into the specified file.
convert(Document.CallBackGetHocr callback, boolean isTestVisible, boolean isOriginalImage)Convert document and save errors into the specified file.
convert(OutputStream outputLogStream, PdfFormat format, int action)
flatten()Removes all fields (and annotations) from the document and place their values instead.
flatten(Form.FlattenSettings flattenSettings)Removes all fields 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 or sets 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.
saveIncrementally(String outputFileName)Saves incrementally the PDF Document to the specified stream.
save(OutputStream outputStream, SaveFormat format)Save document
save(String outputFileName, SaveOptions options)Saves the document with a new name setting its save options.
save(OutputStream outputStream, SaveOptions options)Saves the document with a new name setting its save options.
getId()Gets the ID.
getMetadataStream()Returns raw metadata stream
updatePages()updatePages
suppressUpdate()suppressUpdate
resumeUpdate()resumeUpdate
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.
getPageLabels()Gets page labels in the document.
freeMemory()Clears memory
afterImport()Enumerate all registered annotations and call AfterImport for each of them.
saveXml(String file)Save document to XML.
bindXml(String xmlFile, String xslFile)Bind xml/xsl to document
getObjectById(String id)Gets a object with specified ID in the document.
bindXml(InputStream stream)Bind xml to document
bindXml(String file)Bind xml to document
repair()Repairs broken document.
getEmbedStandardFonts()Property which declares that document must embed all standard Type1 fonts which has flag IsEmbedded set into true.
setEmbedStandardFonts(boolean value)Property which declares that document must embed all standard Type1 fonts which has flag IsEmbedded set into true.
convertInternal(System.IO.Stream log, PdfFormat _convertTo, int none)Internal method
getXmpMetadata(OutputStream stream)Get XMP metadata from document.
setXmpMetadata(InputStream stream)Set XMP metadata of document.
isAbsentFontTryToSubstitute()Notification about missing fonts when processing documents
setAbsentFontTryToSubstitute(boolean setAbsentFontTryToSubstitute)Setting flag for set program determined font in case of absence font.
isXrefGapsAllowed()Gets or sets the is document pdfa compliant.
setXrefGapsAllowed(boolean value)Gets or sets the is document pdfa compliant.
getNamedDestinations()Collection of Named Destination in the document.
check(boolean doRepair)Validates document.
removePdfUaCompliance()Remove pdfUa compliance from the document
setConvertMetadataAndCatalogOnly(boolean value)Gets convert parameter for pdf/ua converter (Convert only Metadata and Document Catalog if set true)
setTitle(String title)Set Title for Pdf 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.

isPdfaCompliant()

public abstract boolean isPdfaCompliant()

Returns: boolean

isPdfUaCompliant()

public abstract boolean isPdfUaCompliant()

Gets the is document pdfua compliant.

Returns: boolean - boolean value

getDestinations()

public abstract DestinationCollection getDestinations()

Gets the collection of destinations.

Returns: DestinationCollection - DestinationCollection object

getPdfFormat()

public abstract PdfFormat getPdfFormat()

Returns: PdfFormat - PdfFormat element

isDisableFontLicenseVerifications()

public abstract boolean isDisableFontLicenseVerifications()

Many operations with font can’t be executed if these operations are prohibited by license of this font. For example some font can’t be embedded into PDF document if license rules disable embedding for this font. This flag is used to disable any license restrictions for all fonts in current PDF document. Be careful when using this flag. When it is set it means that person who sets this flag, takes all responsibility of possible license/law violations on himself. So He takes it on it’s own risk. It’s strongly recommended to use this flag only when you are fully confident that you are not breaking the copyright law.

Returns: boolean - boolean value By default false.

setDisableFontLicenseVerifications(boolean value)

public abstract void setDisableFontLicenseVerifications(boolean value)

Many operations with font can’t be executed if these operations are prohibited by license of this font. For example some font can’t be embedded into PDF document if license rules disable embedding for this font. This flag is used to disable any license restrictions for all fonts in current PDF document. Be careful when using this flag. When it is set it means that person who sets this flag, takes all responsibility of possible license/law violations on himself. So He takes it on it’s own risk. It’s strongly recommended to use this flag only when you are fully confident that you are not breaking the copyright law.

Parameters:

ParameterTypeDescription
valuebooleanboolean value By default false.

removePdfaCompliance()

public abstract void removePdfaCompliance()

Remove pdfa compliance from the document

getCollection()

public abstract Collection getCollection()

Gets collection of document.

Returns: Collection - Collection object

setCollection(Collection value)

public abstract void setCollection(Collection value)

Sets collection of document.

Parameters:

ParameterTypeDescription
valueCollectionCollection object

getEngineDoc()

public abstract IPdfDocument getEngineDoc()

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

Returns: IPdfDocument - IPdfDocument object

getVersion()

public abstract String getVersion()

Gets a version of Pdf from Pdf file header.

Returns: java.lang.String - String object

getOpenAction()

public abstract 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 abstract void setOpenAction(IAppointment value)

Sets action performed at document opening.

Parameters:

ParameterTypeDescription
valueIAppointmentIAppointment object

getOptimizeSize()

public abstract 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 abstract 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 abstract 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 abstract void setIgnoreCorruptedObjects(boolean value)

Parameters:

ParameterTypeDescription
valueboolean

getCatalogValue(String key)

public abstract 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.

isHideToolBar()

public abstract boolean isHideToolBar()

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


Example demonstrates how to get HideToolBar flag:

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

Returns: boolean - boolean value

setHideToolBar(boolean value)

public abstract void setHideToolBar(boolean value)

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

Parameters:

ParameterTypeDescription
valuebooleanboolean value

isHideMenubar()

public abstract boolean isHideMenubar()

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


Example demonstrates how to get HideMenubar flag:

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

Returns: boolean - boolean value

setHideMenubar(boolean value)

public abstract void setHideMenubar(boolean value)

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

Parameters:

ParameterTypeDescription
valuebooleanboolean value

isHideWindowUI()

public abstract boolean isHideWindowUI()

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


Example demonstrates how to get HideWindowUI flag:

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

Returns: boolean - boolean value

setHideWindowUI(boolean value)

public abstract void setHideWindowUI(boolean value)

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

Parameters:

ParameterTypeDescription
valuebooleanboolean value

isFitWindow()

public abstract boolean isFitWindow()

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


Example demonstrates how to get FitWindow flag:

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

Returns: boolean - boolean value

setFitWindow(boolean value)

public abstract 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 abstract boolean isCenterWindow()

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


Example demonstrates how to get CenterWindow flag:

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

Returns: boolean - boolean value

setCenterWindow(boolean value)

public abstract void setCenterWindow(boolean value)

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

Parameters:

ParameterTypeDescription
valuebooleanboolean value

isDisplayDocTitle()

public abstract boolean isDisplayDocTitle()

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


Example demonstrates how to get DisplayDocTitle flag:

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

Returns: boolean - boolean value

setDisplayDocTitle(boolean value)

public abstract void setDisplayDocTitle(boolean value)

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

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getPages()

public abstract PageCollection getPages()

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


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");
 Pages pages = document.getPages();
 System.out.println("Document contains " + pages.size());
 Page page = pages.get_Item(1);
 Rectangle rect = page.getRect();

Returns: PageCollection - boolean value

getOutlines()

public abstract OutlineCollection getOutlines()

Gets document outlines.

Returns: OutlineCollection - OutlineCollection object

getActions()

public abstract DocumentActionCollection getActions()

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


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

 Document document = new Document("PdfWithOpenAction.pdf");
 DocumentActions actions = document.getActions();
 com.aspose.pdf.Action afterSavingAction = actions.getAfterSaving();

Returns: DocumentActionCollection - DocumentActionCollection object

getForm()

public abstract Form getForm()

Gets Acro Form of the document.

Returns: Form - Form object

getEmbeddedFiles()

public abstract EmbeddedFileCollection getEmbeddedFiles()

Gets collection of files embedded to document.

Returns: EmbeddedFileCollection - EmbeddedFileCollection object

getDirection()

public abstract int getDirection()

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

Returns: int - Direction element

setDirection(int value)

public abstract void setDirection(int value)

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

Parameters:

ParameterTypeDescription
valueintDirection element

getPageMode()

public abstract int getPageMode()

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

Returns: int - PageMode element

setPageMode(int value)

public abstract void setPageMode(int value)

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

Parameters:

ParameterTypeDescription
valueintPageMode element

getNonFullScreenPageMode()

public abstract int getNonFullScreenPageMode()

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

Returns: int - PageMode element

setNonFullScreenPageMode(int value)

public abstract void setNonFullScreenPageMode(int value)

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

Parameters:

ParameterTypeDescription
valueintPageMode element

getPageLayout()

public abstract int getPageLayout()

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

Returns: int - PageLayout element

setPageLayout(int value)

public abstract void setPageLayout(int value)

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

Parameters:

ParameterTypeDescription
valueintPageLayout element

getDuplex()

public abstract int getDuplex()

Gets or sets print duplex mode handling option to use when printing the file from the print dialog.

Returns: int - PrintDuplex element

setDuplex(int value)

public abstract void setDuplex(int value)

Gets or sets print duplex mode handling option to use when printing the file from the print dialog.

Parameters:

ParameterTypeDescription
valueintPrintDuplex element

getPrintScaling()

public abstract int getPrintScaling()

Gets print scaling handling option to use when printing the file from the print dialog.

Returns: int - PrintScaling element

setPrintScaling(int value)

public abstract void setPrintScaling(int value)

Sets print scaling handling option to use when printing the file from the print dialog.

Parameters:

ParameterTypeDescription
valueintPrintDuplex element

getFileName()

public abstract String getFileName()

Name of the PDF file that caused this document

Returns: java.lang.String - String object

getPageInfo()

public abstract PageInfo getPageInfo()

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

Returns: PageInfo - The page info.

setPageInfo(PageInfo value)

public abstract void setPageInfo(PageInfo value)

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

Parameters:

ParameterTypeDescription
valuePageInfoPageInfo object

getEnableSignatureSanitization()

public abstract boolean getEnableSignatureSanitization()

Gets or sets flag to manage signature fields sanitization. Enabled by default.

Returns: boolean - boolean value

setEnableSignatureSanitization(boolean value)

public abstract void setEnableSignatureSanitization(boolean value)

Gets or sets flag to manage signature fields sanitization. Enabled by default.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getInfo()

public abstract DocumentInfo getInfo()

Gets document info.

Returns: DocumentInfo - DocumentInfo object

getMetadata()

public abstract 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 abstract RootElement getLogicalStructure()

Gets logical structure of the document.

Returns: RootElement - RootElement object

processParagraphs()

public abstract void processParagraphs()

Stores document into stream.

save(OutputStream output)

public abstract void save(OutputStream output)

Stores document into stream.

Parameters:

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

saveIncrementally(OutputStream output)

public abstract 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 abstract void saveIncrementally(System.IO.Stream output)

Saves incrementally the PDF Document to the specified stream.

Parameters:

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

save(String outputFileName)

public abstract 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 abstract void exportAnnotationsToXfdf(String fileName)

Exports all document annotations to XFDF file

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringXFDF file name

sendTo(DocumentDevice device, OutputStream output)

public abstract void sendTo(DocumentDevice device, OutputStream output)

Sends the whole document to the document device for processing.

Parameters:

ParameterTypeDescription
deviceDocumentDeviceDocumentDevice object
outputjava.io.OutputStreamOutputStream object

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

public abstract 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 abstract 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 abstract 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 abstract void removeMetadata()

Removes metadata from the document.

importAnnotationsFromXfdf(String fileName)

public abstract void importAnnotationsFromXfdf(String fileName)

Imports annotations from XFDF file to document.

Parameters:

ParameterTypeDescription
fileNamejava.lang.StringXFDF file name

validate(String outputLogFileName, PdfFormat format)

public abstract 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.
formatPdfFormatPdf format.

Returns: boolean - boolean value

validate(OutputStream outputLogStream, PdfFormat format)

public abstract 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 - The operation result

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

public abstract 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(String outputLogFileName, PdfFormat format, int action)

public abstract 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 - The operation result

convert(PdfFormatConversionOptions options)

public abstract 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(Document.CallBackGetHocr callback)

public abstract boolean convert(Document.CallBackGetHocr callback)

Convert document to searchable document.

Parameters:

ParameterTypeDescription
callbackCallBackGetHocrThe call back procedure for hocr recognize.

Returns: boolean - boolean value

convertWithSkippingErrors(Document.CallBackGetHocr callback)

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

convert(Document.CallBackGetHocr callback, boolean isTestVisible)

public abstract boolean convert(Document.CallBackGetHocr callback, boolean isTestVisible)

Convert document and save errors into the specified file.

This is allow to show/hide searchable text on page. Default value is FALSE.

Parameters:

ParameterTypeDescription
callbackCallBackGetHocrAction for objects that can not be converted
isTestVisiblebooleanboolean value

Returns: boolean - The operation result

convert(Document.CallBackGetHocr callback, boolean isTestVisible, boolean isOriginalImage)

public abstract boolean convert(Document.CallBackGetHocr callback, boolean isTestVisible, boolean isOriginalImage)

Convert document and save errors into the specified file.

This is allow to show/hide searchable text on page. Default value is FALSE. This is allow to getting original image from pdf. Default value is FALSE.

Parameters:

ParameterTypeDescription
callbackCallBackGetHocrAction for objects that can not be converted
isTestVisiblebooleanboolean value
isOriginalImagebooleanboolean value

Returns: boolean - The operation result

convert(OutputStream outputLogStream, PdfFormat format, int action)

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

Parameters:

ParameterTypeDescription
outputLogStreamjava.io.OutputStream
formatPdfFormat
actionint

Returns: boolean

flatten()

public abstract void flatten()

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

flatten(Form.FlattenSettings flattenSettings)

public abstract void flatten(Form.FlattenSettings flattenSettings)

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

Parameters:

ParameterTypeDescription
flattenSettingsFlattenSettingsSettings for flattening process.

flattenTransparency()

public abstract void flattenTransparency()

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

getCryptoAlgorithm()

public abstract CryptoAlgorithm getCryptoAlgorithm()

Gets security settings if document is encrypted. If document is not encrypted then will be null

Returns: CryptoAlgorithm - CryptoAlgorithm element or null

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

public abstract 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 abstract 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 abstract 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 abstract 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 abstract boolean isLinearized()

Gets or sets a value indicating whether document is linearized.

Returns: boolean - boolean value

setLinearized(boolean value)

public abstract void setLinearized(boolean value)

Sets a value indicating whether document is linearized.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

decrypt()

public abstract void decrypt()

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

getPermissions()

public abstract int getPermissions()

Gets permissions of the document.

Returns: int - int value

isEncrypted()

public abstract boolean isEncrypted()

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

Returns: boolean - boolean value

optimize()

public abstract 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 abstract 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.

saveIncrementally(String outputFileName)

public abstract void saveIncrementally(String outputFileName)

Saves incrementally the PDF Document to the specified stream.

Parameters:

ParameterTypeDescription
outputFileNamejava.lang.StringString value

save(OutputStream outputStream, SaveFormat format)

public abstract void save(OutputStream outputStream, SaveFormat format)

Save document

Parameters:

ParameterTypeDescription
outputStreamjava.io.OutputStreamOutputStream object
formatSaveFormatSaveFormat value

save(String outputFileName, SaveOptions options)

public abstract 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 abstract void save(OutputStream outputStream, SaveOptions options)

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

Parameters:

ParameterTypeDescription
outputStreamjava.io.OutputStreamOutputStream where the document will be stored.
optionsSaveOptionsSave options.

getId()

public abstract Id getId()

Gets the ID.

Returns: Id - Id object

getMetadataStream()

public abstract IPdfStreamAccessor getMetadataStream()

Returns raw metadata stream

Returns: IPdfStreamAccessor - IPdfStreamAccessor object

updatePages()

public abstract void updatePages()

updatePages

suppressUpdate()

public abstract void suppressUpdate()

suppressUpdate

resumeUpdate()

public abstract void resumeUpdate()

resumeUpdate

dispose()

public abstract void dispose()

Closes all resources used by this document.

This method is obsoleted, use close() instead.

close()

public abstract void close()

Closes all resources used by this document.

getBackground()

public abstract Color getBackground()

Gets the background color of the document.

Returns: Color - java.awt.Color object

setBackground(Color value)

public abstract void setBackground(Color value)

Sets the background color of the document.

Parameters:

ParameterTypeDescription
valuejava.awt.Colorjava.awt.Color object

getDefaultCopier()

public abstract Copier getDefaultCopier()

Returns copier used for coping pages to this document.

Returns: Copier - Copier object

optimizeResources()

public abstract 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 abstract void optimizeResources(OptimizationOptions strategy)

Optimize resources in the document according to defined optimization strategy.

Parameters:

ParameterTypeDescription
strategyOptimizationOptionsOptimization strategy.

getPageLabels()

public abstract PageLabelCollection getPageLabels()

Gets page labels in the document.

Returns: PageLabelCollection - PageLabelCollection object

freeMemory()

public abstract void freeMemory()

Clears memory

afterImport()

public abstract void afterImport()

Enumerate all registered annotations and call AfterImport for each of them.

saveXml(String file)

public abstract void saveXml(String file)

Save document to XML.

Parameters:

ParameterTypeDescription
filejava.lang.StringThe document model xml file

bindXml(String xmlFile, String xslFile)

public abstract void bindXml(String xmlFile, String xslFile)

Bind xml/xsl to document

Parameters:

ParameterTypeDescription
xmlFilejava.lang.StringThe xml file.
xslFilejava.lang.StringThe xsl file if XSLT is used.

getObjectById(String id)

public abstract Object getObjectById(String id)

Gets a object with specified ID in the document.

Parameters:

ParameterTypeDescription
idjava.lang.StringThe object id.

Returns: java.lang.Object - The object with specified id. Null if the id is not found.

bindXml(InputStream stream)

public abstract void bindXml(InputStream stream)

Bind xml to document

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamThe stream with xml file

bindXml(String file)

public abstract void bindXml(String file)

Bind xml to document

Parameters:

ParameterTypeDescription
filejava.lang.StringThe xml file

repair()

public abstract void repair()

Repairs broken document.

getEmbedStandardFonts()

public abstract boolean getEmbedStandardFonts()

Property which declares that document must embed all standard Type1 fonts which has flag IsEmbedded set into true. All PDF fonts can be embedded into document simply via setting of flag IsEmbedded into true, but PDF standard Type1 fonts is an exception from this rule. Standard Type1 font embedding requires much time, so to embed these fonts it’s necessary not only set flag IsEmbedded into true for specified font but also set an additiona flag on document’s level - EmbedStandardFonts = true; This property can be set only one time for all fonts. By default false.

Returns: boolean - boolean value

setEmbedStandardFonts(boolean value)

public abstract void setEmbedStandardFonts(boolean value)

Property which declares that document must embed all standard Type1 fonts which has flag IsEmbedded set into true. All PDF fonts can be embedded into document simply via setting of flag IsEmbedded into true, but PDF standard Type1 fonts is an exception from this rule. Standard Type1 font embedding requires much time, so to embed these fonts it’s necessary not only set flag IsEmbedded into true for specified font but also set an additiona flag on document’s level - EmbedStandardFonts = true; This property can be set only one time for all fonts. By default false.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

convertInternal(System.IO.Stream log, PdfFormat _convertTo, int none)

public abstract boolean convertInternal(System.IO.Stream log, PdfFormat _convertTo, int none)

Internal method

Parameters:

ParameterTypeDescription
logcom.aspose.ms.System.IO.StreamInternal object
_convertToPdfFormatInternal object
noneintInternal object

Returns: boolean - Internal value

getXmpMetadata(OutputStream stream)

public abstract void getXmpMetadata(OutputStream stream)

Get XMP metadata from document.

Parameters:

ParameterTypeDescription
streamjava.io.OutputStreamStream where metadata will be stored.

setXmpMetadata(InputStream stream)

public abstract void setXmpMetadata(InputStream stream)

Set XMP metadata of document.

Parameters:

ParameterTypeDescription
streamjava.io.InputStreamStream which contains XMP metadata.

isAbsentFontTryToSubstitute()

public abstract boolean isAbsentFontTryToSubstitute()

Notification about missing fonts when processing documents

Returns: boolean - boolean value

setAbsentFontTryToSubstitute(boolean setAbsentFontTryToSubstitute)

public abstract void setAbsentFontTryToSubstitute(boolean setAbsentFontTryToSubstitute)

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

Parameters:

ParameterTypeDescription
setAbsentFontTryToSubstitutebooleanboolean value

isXrefGapsAllowed()

public abstract boolean isXrefGapsAllowed()

Gets or sets the is document pdfa compliant.

Returns: boolean - boolean value

setXrefGapsAllowed(boolean value)

public abstract void setXrefGapsAllowed(boolean value)

Gets or sets the is document pdfa compliant.

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getNamedDestinations()

public abstract NamedDestinationCollection getNamedDestinations()

Collection of Named Destination in the document.

Returns: NamedDestinationCollection - NamedDestinationCollection instance

check(boolean doRepair)

public abstract boolean check(boolean doRepair)

Validates document.

Parameters:

ParameterTypeDescription
doRepairbooleanIf true found issues will be repaired.

Returns: boolean - boolean value

removePdfUaCompliance()

public abstract void removePdfUaCompliance()

Remove pdfUa compliance from the document

setConvertMetadataAndCatalogOnly(boolean value)

public abstract void setConvertMetadataAndCatalogOnly(boolean value)

Gets convert parameter for pdf/ua converter (Convert only Metadata and Document Catalog if set true)

Parameters:

ParameterTypeDescription
valuebooleanboolean value

setTitle(String title)

public abstract void setTitle(String title)

Set Title for Pdf Document

Parameters:

ParameterTypeDescription
titlejava.lang.StringDocument’s title

isManualDisposeEnabled()

public abstract 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 abstract 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 abstract 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 abstract 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. Do not call this method while iterating over Pages elements, it may give unpredictable results

Parameters:

ParameterTypeDescription
nodesNumInSubtreesbyteDesired number of subnodes. Default value is ten.