com.aspose.pdf

Interfaces

Classes

Enums

Exceptions

com.aspose.pdf

Class Document

  • All Implemented Interfaces:
    com.aspose.ms.System.IDisposable, IDocument


    public final class Document
    extends Object
    implements IDocument

    Class representing PDF document

    • Field Detail

      • AbsentFontHandler

        public com.aspose.pdf.ADocument.AbsentFontHandler AbsentFontHandler
        Notification about missing fonts while processing documents.
      • FontSubstitution

        public final PdfEvent<com.aspose.pdf.ADocument.FontSubstitutionHandler> FontSubstitution

        It occurs when font replaces another font in document.

    • Constructor Detail

      • Document

        public Document()

        Initializes empty document.

      • Document

        public Document(InputStream input)

        Initialize new Document instance from the input stream.

        Parameters:
        input - Stream with pdf document.
      • Document

        public Document(InputStream input,
                String password)

        Initialize new Document instance from the input stream.

        Parameters:
        input - Input stream object, corresponding pdf is password protected.
        password - User or owner password.
      • Document

        public Document(com.aspose.ms.System.IO.Stream input)

        Initialize new Document instance from the input stream.

        Parameters:
        input - Stream with pdf document.
      • Document

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

        Initialize new Document instance from the input stream.

        Parameters:
        input - Stream with pdf document.
        password - User or owner password.
        isManagedStream - if set to true inner stream is closed before exit; otherwise, is not.
      • Document

        public Document(InputStream input,
                boolean isManagedStream)

        Initialize new Document instance from the input stream.

        Parameters:
        input - Stream with pdf document.
        isManagedStream - if set to true inner stream is closed before exit; otherwise, is not.
      • Document

        public Document(InputStream input,
                LoadOptions options)

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

        Parameters:
        input - Input stream to convert into pdf document.
        options - Represents properties for converting input into pdf document.
      • Document

        public Document(String filename,
                LoadOptions options)

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

        Parameters:
        filename - Input file to convert into pdf document.
        options - Represents properties for converting filename into pdf document.
      • Document

        public Document(com.aspose.ms.System.IO.Stream input,
                String password)
      • Document

        public Document(String filename)

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

        Parameters:
        filename - The name of the pdf document file.
      • Document

        public Document(String filename,
                String password)

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

        Parameters:
        filename - Document file name.
        password - User or owner password.
      • Document

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

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

        Parameters:
        filename - Document file name.
        password - User or owner password.
        isManagedStream - if set to true inner stream is closed before exit; otherwise, is not.
    • Method Detail

      • getLocalFontPaths

        public static List<String> getLocalFontPaths()

        Copy of the list with actual font directories.

        Returns:
        list of String
      • addLocalFontPath

        public static void addLocalFontPath(String path)

        Add one more path to fonts.

        Parameters:
        path - String value
      • setLocalFontPaths

        public static void setLocalFontPaths(List<String> newFontPathsList)

        Sets user list with font paths

        Parameters:
        newFontPathsList - List<String> object
      • restoreLocalFontPath

        public static void restoreLocalFontPath()

        Restores list for standard font directories by default.

      • getPageInfo

        public PageInfo getPageInfo()

        Gets the page info.(for generator only)

        Specified by:
        getPageInfo in interface IDocument
        Returns:
        The page info.
      • setPageInfo

        public void setPageInfo(PageInfo value)

        Sets the page info.(for generator only)

        Specified by:
        setPageInfo in interface IDocument
        Parameters:
        value - PageInfo object
      • getPdfaFormat

        public int getPdfaFormat()

        Gets pdfa format

        Specified by:
        getPdfaFormat in interface IDocument
        Returns:
        PdfFormat element
        See Also:
        PdfFormat
      • removePdfaCompliance

        public void removePdfaCompliance()

        Remove pdfa compliance from the document

        Specified by:
        removePdfaCompliance in interface IDocument
      • setCollection

        public void setCollection(Collection value)

        Sets collection of document.

        Specified by:
        setCollection in interface IDocument
        Parameters:
        value - Collection object
      • getEngineDoc

        public com.aspose.pdf.engine.IPdfDocument getEngineDoc()

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

        Specified by:
        getEngineDoc in interface IDocument
        Returns:
        IPdfDocument object
      • getVersion

        public String getVersion()

        Gets a version of Pdf from Pdf file header.

        Specified by:
        getVersion in interface IDocument
        Returns:
        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();
         
        Specified by:
        getOpenAction in interface IDocument
        Returns:
        IAppointment object
      • setOpenAction

        public void setOpenAction(IAppointment value)

        Sets action performed at document opening.

        Specified by:
        setOpenAction in interface IDocument
        Parameters:
        value - IAppointment value
      • getHideToolBar

        public boolean getHideToolBar()

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

        Specified by:
        getHideToolBar in interface IDocument
        Returns:
        boolean value
         Example demonstrates how to get HideToolBar flag:
         
         Document document = new Document("sample.pdf");
         boolean value = document.getHideToolBar();
         
      • setHideToolBar

        public void setHideToolBar(boolean value)

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

        Specified by:
        setHideToolBar in interface IDocument
        Parameters:
        value - boolean value
      • getHideMenubar

        public boolean getHideMenubar()

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

        Specified by:
        getHideMenubar in interface IDocument
        Returns:
        boolean value
         Example demonstrates how to get HideMenubar flag:
         
         Document document = new Document("sample.pdf");
         boolean value = document.getHideMenubar();
         
      • setHideMenubar

        public void setHideMenubar(boolean value)

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

        Specified by:
        setHideMenubar in interface IDocument
        Parameters:
        value - boolean value
      • getHideWindowUI

        public boolean getHideWindowUI()

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

        Specified by:
        getHideWindowUI in interface IDocument
        Returns:
        boolean value
         Example demonstrates how to get HideWindowUI flag:
         
         Document document = new Document("sample.pdf");
         boolean value = document.getHideWindowUI();
         
      • setHideWindowUI

        public void setHideWindowUI(boolean value)

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

        Specified by:
        setHideWindowUI in interface IDocument
        Parameters:
        value - boolean value
      • getFitWindow

        public boolean getFitWindow()

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

        Specified by:
        getFitWindow in interface IDocument
        Returns:
        boolean value
         Example demonstrates how to get FitWindow flag:
         
         Document document = new Document("sample.pdf");
         boolean value = document.getFitWindow();
         
      • setFitWindow

        public void setFitWindow(boolean value)

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

        Specified by:
        setFitWindow in interface IDocument
        Parameters:
        value - boolean value
      • getCenterWindow

        public boolean getCenterWindow()

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

        Specified by:
        getCenterWindow in interface IDocument
        Returns:
        boolean value
         Example demonstrates how to get CenterWindow flag:
         
         Document document = new Document("sample.pdf");
         boolean value = document.getCenterWindow();
         
      • setCenterWindow

        public void setCenterWindow(boolean value)

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

        Specified by:
        setCenterWindow in interface IDocument
        Parameters:
        value - boolean value
      • getDisplayDocTitle

        public boolean getDisplayDocTitle()

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

        Specified by:
        getDisplayDocTitle in interface IDocument
        Returns:
        boolean value
         Example demonstrates how to get DisplayDocTitle flag:
         
         Document document = new Document("sample.pdf");
         boolean value = document.getDisplayDocTitle();
         
      • setDisplayDocTitle

        public void setDisplayDocTitle(boolean value)

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

        Specified by:
        setDisplayDocTitle in interface IDocument
        Parameters:
        value - boolean value
      • getPages

        public PageCollection getPages()

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

        Specified by:
        getPages in interface IDocument
        Returns:
        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();
         
      • getActions

        public DocumentActionCollection getActions()

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

        Specified by:
        getActions in interface IDocument
        Returns:
        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.

        Specified by:
        getForm in interface IDocument
        Returns:
        Form object
      • getDirection

        public int getDirection()

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

        Specified by:
        getDirection in interface IDocument
        Returns:
        Direction element
        See Also:
        Direction
      • setDirection

        public void setDirection(int value)

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

        Specified by:
        setDirection in interface IDocument
        Parameters:
        value - int value
        See Also:
        Direction
      • getPageMode

        public int getPageMode()

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

        Specified by:
        getPageMode in interface IDocument
        Returns:
        PageMode element
        See Also:
        PageMode
      • setPageMode

        public void setPageMode(int pageMode)

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

        Specified by:
        setPageMode in interface IDocument
        Parameters:
        pageMode - int value
        See Also:
        PageMode
      • getNonFullScreenPageMode

        public int getNonFullScreenPageMode()

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

        Specified by:
        getNonFullScreenPageMode in interface IDocument
        Returns:
        PageMode element
        See Also:
        PageMode
      • setNonFullScreenPageMode

        public void setNonFullScreenPageMode(int value)

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

        Specified by:
        setNonFullScreenPageMode in interface IDocument
        Parameters:
        value - int value
        See Also:
        PageMode
      • getPageLayout

        public int getPageLayout()

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

        Specified by:
        getPageLayout in interface IDocument
        Returns:
        PageLayout element
        See Also:
        PageLayout
      • setPageLayout

        public void setPageLayout(int value)

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

        Specified by:
        setPageLayout in interface IDocument
        Parameters:
        value - int value
        See Also:
        PageLayout
      • getFileName

        public String getFileName()

        Name of the PDF file that caused this document

        Specified by:
        getFileName in interface IDocument
        Returns:
        String 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.)

        Specified by:
        getMetadata in interface IDocument
        Returns:
        Metadata object
      • processParagraphs

        public void processParagraphs()

        Stores document into stream.

        Specified by:
        processParagraphs in interface IDocument
      • saveInternal

        public void saveInternal(com.aspose.ms.System.IO.Stream output)

        For internal usage only

        Specified by:
        saveInternal in interface IDocument
        Parameters:
        output - For internal usage only
      • save

        public void save(OutputStream output)

        Stores document into stream.

        Specified by:
        save in interface IDocument
        Parameters:
        output - Stream where document shell be stored.
      • save

        public void save(String outputFileName)

        Saves document into the specified file.

        Specified by:
        save in interface IDocument
        Parameters:
        outputFileName - Path to file where the document will be stored.
      • exportAnnotationsToXfdf

        public void exportAnnotationsToXfdf(String fileName)

        Exports all document annotations to XFDF file

        Specified by:
        exportAnnotationsToXfdf in interface IDocument
        Parameters:
        fileName - XFDF file name
      • sendTo

        public void sendTo(DocumentDevice device,
                  OutputStream output)

        Sends the whole document to the document device for processing.

        Specified by:
        sendTo in interface IDocument
        Parameters:
        device - Document device which is used to process the document.
        output - Output stream contains the results of the document processing with given device.
      • sendTo

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

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

        Specified by:
        sendTo in interface IDocument
        Parameters:
        device - Document device which is used to process the document.
        fromPage - The first page for processing.
        toPage - The last page for processing.
        output - Output stream contains the results of the document pages processing with given device.
      • sendTo

        public void sendTo(DocumentDevice device,
                  String outputFileName)

        Sends the whole document to the document device for processing.

        Specified by:
        sendTo in interface IDocument
        Parameters:
        device - Document device which is used to process the document.
        outputFileName - Output file name with the results of processing.
      • sendTo

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

        Sends the whole document to the document device for processing.

        Specified by:
        sendTo in interface IDocument
        Parameters:
        device - Document device which is used to process the document.
        fromPage - The first page for processing.
        toPage - The last page for processing.
        outputFileName - Output file name with the results of processing.
      • removeMetadata

        public void removeMetadata()

        Removes metadata from the document.

        Specified by:
        removeMetadata in interface IDocument
      • importAnnotationsFromXfdf

        public void importAnnotationsFromXfdf(String fileName)

        Imports annotations from XFDF file to document.

        Specified by:
        importAnnotationsFromXfdf in interface IDocument
        Parameters:
        fileName - XFDF file name
      • validate

        public boolean validate(String outputLogFileName,
                       int format)

        Validate document into the specified file.

        Specified by:
        validate in interface IDocument
        Parameters:
        outputLogFileName - Path to file where the comments will be stored.
        format - PdfFormat element.
        Returns:
        The operation result
        See Also:
        PdfFormat
      • convert

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

        Convert document and save errors into the specified file.

        Specified by:
        convert in interface IDocument
        Parameters:
        outputLogFileName - Path to file where the comments will be stored.
        format - Pdf format.
        action - Action for objects that can not be converted
        Returns:
        boolean value
        See Also:
        PdfFormat, ConvertErrorAction
      • validate

        public boolean validate(OutputStream outputLogStream,
                       int format)
        Validate document into the specified file.
        Specified by:
        validate in interface IDocument
        Parameters:
        outputLogStream - Stream where the comments will be stored.
        format - Pdf format.
        Returns:
        boolean value
        See Also:
        PdfFormat
      • convert

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

        Convert document and save errors into the specified file.

        Specified by:
        convert in interface IDocument
        Parameters:
        outputLogFileName - Path to file where the comments will be stored.
        format - The pdf format.
        action - Action for objects that can not be converted
        transparencyAction - Action for image masked objects
        Returns:
        The operation result
        See Also:
        PdfFormat, ConvertErrorAction, ConvertTransparencyAction
      • convert

        public boolean convert(Document.CallBackGetHocr callback)
        Convert document and save errors into the specified file.
        Specified by:
        convert in interface IDocument
        Parameters:
        callback - Action for objects that can not be converted
        Returns:
        boolean value
      • convertInternal

        public boolean convertInternal(com.aspose.ms.System.IO.Stream outputLogStream,
                              int format,
                              int action)

        Convert document and save errors into the specified stream.

        Specified by:
        convertInternal in interface IDocument
        Parameters:
        outputLogStream - Stream where the comments will be stored.
        format - Pdf format.
        action - Action for objects that can not be converted
        Returns:
        boolean value
      • convert

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

        Convert document and save errors into the specified stream.

        Specified by:
        convert in interface IDocument
        Parameters:
        outputLogStream - Stream where the comments will be stored.
        format - Pdf format.
        action - Action for objects that can not be converted
        Returns:
        boolean value
        See Also:
        PdfFormat, ConvertErrorAction
      • convert

        public boolean convert(PdfFormatConversionOptions options)

        Convert document using specified conversion options

        Specified by:
        convert in interface IDocument
        Parameters:
        options - set of options for convert PDF document
        Returns:
        The operation result
      • flatten

        public void flatten()

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

        Specified by:
        flatten in interface IDocument
      • getCryptoAlgorithm

        public int getCryptoAlgorithm()

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

        Specified by:
        getCryptoAlgorithm in interface IDocument
        Returns:
        CryptoAlgorithm element
        See Also:
        CryptoAlgorithm
      • encrypt

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

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

        Specified by:
        encrypt in interface IDocument
        Parameters:
        userPassword - User password.
        ownerPassword - Owner password.
        privileges - Document permissions, see Permissions for details.
        cryptoAlgorithm - Cryptographic algorithm, see CryptoAlgorithm for details.
        usePdf20 - Support for revision 6 (Extension 8).
        See Also:
        CryptoAlgorithm
      • encrypt

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

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

        Specified by:
        encrypt in interface IDocument
        Parameters:
        userPassword - User password.
        ownerPassword - Owner password.
        permissions - Document permissions, see Permissions for details.
        cryptoAlgorithm - Cryptographic algorithm, see CryptoAlgorithm for details.
        See Also:
        Permissions, CryptoAlgorithm
      • encrypt

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

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

        Specified by:
        encrypt in interface IDocument
        Parameters:
        userPassword - User password.
        ownerPassword - Owner password.
        permissions - Document permissions, see Permissions for details.
        cryptoAlgorithm - Cryptographic algorithm, see CryptoAlgorithm for details.
        usePdf20 - Support for revision 6 (Extension 8).
        See Also:
        Permissions, CryptoAlgorithm
      • changePasswords

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

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

        Specified by:
        changePasswords in interface IDocument
        Parameters:
        ownerPassword - Owner password.
        newUserPassword - New user password.
        newOwnerPassword - New owner password.
      • isLinearized

        public boolean isLinearized()

        Gets a value indicating whether document is linearized.

        Specified by:
        isLinearized in interface IDocument
        Returns:
        boolean value
      • setLinearized

        public void setLinearized(boolean value)

        Sets a value indicating whether document is linearized.

        Specified by:
        setLinearized in interface IDocument
        Parameters:
        value - boolean value
      • decrypt

        public void decrypt()

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

        Specified by:
        decrypt in interface IDocument
      • getPermissions

        public int getPermissions()

        Gets permissions of the document.

        Specified by:
        getPermissions in interface IDocument
        Returns:
        int value
      • isEncrypted

        public boolean isEncrypted()

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

        Specified by:
        isEncrypted in interface IDocument
        Returns:
        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.

        Specified by:
        optimize in interface IDocument
      • save

        public void save()

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


        In order to save document incrementally we should open the document file for writing. Therefore Document must be initialized with writable stream like in the next code snippet: Document doc = new Document(new FileStream("document.pdf", FileMode.Open, FileAccess.ReadWrite)); // make some changes and save the document incrementally doc.Save();

        Specified by:
        save in interface IDocument
      • save

        public void save(String outputFileName,
                int format)

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

        Parameters:
        outputFileName - Path to file where the document will be stored.
        format - Format options.
        See Also:
        SaveFormat
      • save

        public void save(OutputStream outputStream,
                int format)

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

        Specified by:
        save in interface IDocument
        Parameters:
        outputStream - Stream where the document will be stored.
        format - Format options.
        Throws:
        com.aspose.ms.System.ArgumentException - ArgumentException when HtmlSaveOptions is passed to a method. Save a document to the html stream is not supported. Please use method save to the file.
        See Also:
        SaveFormat
      • save

        public void save(String outputFileName,
                SaveOptions options)

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

        Specified by:
        save in interface IDocument
        Parameters:
        outputFileName - Path to file where the document will be stored.
        options - Save options.
      • save

        public void save(OutputStream outputStream,
                SaveOptions options)

        Saves the document to a stream with a save options.

        Specified by:
        save in interface IDocument
        Parameters:
        outputStream - Stream where the document will be stored.
        options - Save options.
        Throws:
        com.aspose.ms.System.ArgumentException - ArgumentException when HtmlSaveOptions is passed to a method. Save a document to the html stream is not supported. Please use method save to the file.
      • getId

        public Id getId()

        Gets the ID.

        Specified by:
        getId in interface IDocument
        Returns:
        Id object
      • getMetadataStream

        public com.aspose.pdf.engine.data.types.IPdfStreamAccessor getMetadataStream()

        Returns raw metadata stream

        Specified by:
        getMetadataStream in interface IDocument
        Returns:
        IPdfStreamAccessor object
      • suppressUpdate

        public void suppressUpdate()

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

        Specified by:
        suppressUpdate in interface IDocument
      • resumeUpdate

        public void resumeUpdate()

        resumes document update

        Specified by:
        resumeUpdate in interface IDocument
      • dispose

        public void dispose()

        Closes all resources used by this document.

        Specified by:
        dispose in interface com.aspose.ms.System.IDisposable
        Specified by:
        dispose in interface IDocument
      • getBackground

        public Color getBackground()

        Gets the background color of the document.

        Specified by:
        getBackground in interface IDocument
        Returns:
        Color object
      • setBackground

        public void setBackground(Color value)

        Sets the background color of the document.

        Specified by:
        setBackground in interface IDocument
        Parameters:
        value - Color object
      • getDefaultCopier

        public Copier getDefaultCopier()

        Returns copier used for coping pages to this document.

        Specified by:
        getDefaultCopier in interface IDocument
        Returns:
        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.

        Specified by:
        optimizeResources in interface IDocument
      • optimizeResources

        public void optimizeResources(Document.OptimizationOptions strategy)

        Optimize resources in the document according to defined optimization strategy.

        Specified by:
        optimizeResources in interface IDocument
        Parameters:
        strategy - Optimization strategy.
      • getOptimizeSize

        public boolean getOptimizeSize()

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

        Specified by:
        getOptimizeSize in interface IDocument
        Returns:
        boolean value
      • setOptimizeSize

        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.

        Specified by:
        setOptimizeSize in interface IDocument
        Parameters:
        value - boolean value
      • getIgnoreCorruptedObjects

        public boolean getIgnoreCorruptedObjects()

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

        Specified by:
        getIgnoreCorruptedObjects in interface IDocument
        Returns:
        boolean value
      • setIgnoreCorruptedObjects

        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.

        Specified by:
        setIgnoreCorruptedObjects in interface IDocument
        Parameters:
        value - boolean value
      • getCatalogValue

        public Object getCatalogValue(String key)

        Returns item value from catalog dictionary.

        Specified by:
        getCatalogValue in interface IDocument
        Parameters:
        key - The key of item.
        Returns:
        Item value - if key was successfully found; otherwise, null.
      • freeMemory

        public void freeMemory()

        Clears memory

        Specified by:
        freeMemory in interface IDocument
      • isAbsentFontTryToSubstitute

        public boolean isAbsentFontTryToSubstitute()
        Flag which informs about replacement of missing font.
        Specified by:
        isAbsentFontTryToSubstitute in interface IDocument
        Returns:
        boolean value
      • setAbsentFontTryToSubstitute

        public void setAbsentFontTryToSubstitute(boolean setAbsentFontTryToSubstitute)
        Setting flag for set program determined font in case of absense font.
        Specified by:
        setAbsentFontTryToSubstitute in interface IDocument
        Parameters:
        setAbsentFontTryToSubstitute - boolean value
      • getJavaScript

        public JavaScriptCollection getJavaScript()

        Collection of JavaScript of document level.

        Returns:
        JavaScriptCollection object
      • isLicensed

        public static boolean isLicensed()

        Gets licensed state of the system. Returns true is system works in licensed mode and false otherwise.

        Returns:
        boolean value
      • setLayersAdded

        public void setLayersAdded(boolean value)
        Description copied from interface: IDocument
        Set LayersAdded value
        Specified by:
        setLayersAdded in interface IDocument
        Parameters:
        value - boolean value
      • startOperation

        public static void startOperation()
      • endOperation

        public static void endOperation()
      • isPdfaCompliant

        public boolean isPdfaCompliant()

        Gets the is document pdfa compliant.

        Specified by:
        isPdfaCompliant in interface IDocument
        Returns:
        boolean value
      • isXrefGapsAllowed

        public boolean isXrefGapsAllowed()

        Gets or sets the is document pdfa compliant.

        Specified by:
        isXrefGapsAllowed in interface IDocument
        Returns:
        boolean value
      • setXrefGapsAllowed

        public void setXrefGapsAllowed(boolean value)

        Gets or sets the is document pdfa compliant.

        Specified by:
        setXrefGapsAllowed in interface IDocument
        Parameters:
        value - boolean value
      • getEmbedStandardFonts

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

        Specified by:
        getEmbedStandardFonts in interface IDocument
        Returns:
        boolean value
      • setEmbedStandardFonts

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

        Specified by:
        setEmbedStandardFonts in interface IDocument
        Parameters:
        value - boolean value
      • save

        public void save(com.aspose.ms.System.IO.FileStream output)
        Description copied from interface: IDocument
        Internal method
        Specified by:
        save in interface IDocument
        Parameters:
        output - intermal object.
      • validate

        public boolean validate(PdfFormatConversionOptions options)

        Validate document into the specified file.

        Parameters:
        options - set of options for convert PDF document
        Returns:
        The operation result
      • convert

        public boolean convert(Document.CallBackGetHocr callback,
                      boolean isTestVisible)
        Convert document and save errors into the specified file. This is allow to show/hide searchable text. Default value is FALSE.
        Specified by:
        convert in interface IDocument
        Parameters:
        callback - Action for objects that can not be converted
        isTestVisible - boolean value
        Returns:
        The operation result
      • flatten

        public void flatten(Form.FlattenSettings flattenSettings)

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

        Parameters:
        flattenSettings - Settings for flattening process.
      • updatePages

        public void updatePages()
        Description copied from interface: IDocument
        updatePages
        Specified by:
        updatePages in interface IDocument
      • close

        public void close()

        Closes all resources used by this document.

      • getAllowReusePageContent

        public boolean getAllowReusePageContent()

        Allows to merge page contents to optimize docuement size. If used then differnet but duplicated pages may reference to the same content object. Please note that this mode may cause side effects like changing page content when other page is changed.

        Returns:
        value boolean value
      • setAllowReusePageContent

        public void setAllowReusePageContent(boolean value)

        Allows to merge page contents to optimize docuement size. If used then differnet but duplicated pages may reference to the same content object. Please note that this mode may cause side effects like changing page content when other page is changed.

        Parameters:
        value - boolean value
      • afterImport

        public void afterImport()

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

        Specified by:
        afterImport in interface IDocument
      • saveXml

        public void saveXml(String file)

        Save document to XML.

        Specified by:
        saveXml in interface IDocument
        Parameters:
        file - The document model xml file
      • getObjectById

        public Object getObjectById(String id)

        Gets a object with specified ID in the document.

        Specified by:
        getObjectById in interface IDocument
        Parameters:
        id - The object id.
        Returns:
        The object with specified id. Null if the id is not found.
      • bindXml

        public void bindXml(String file)

        Bind xml to document

        Specified by:
        bindXml in interface IDocument
        Parameters:
        file - The xml file
      • repair

        public void repair()
        Repairs broken document.
        Specified by:
        repair in interface IDocument
      • bindXml

        public void bindXml(String xmlFile,
                   String xslFile)

        Bind xml/xsl to document

        Specified by:
        bindXml in interface IDocument
        Parameters:
        xmlFile - The xml file.
        xslFile - The xsl file if XSLT is used.
      • bindXml

        public void bindXml(InputStream xmlStream,
                   InputStream xslStream)

        Bind xml/xsl to document

        Parameters:
        xmlStream - The xml stream.
        xslStream - The xsl stream if XSLT is used.
      • bindXml

        public void bindXml(InputStream xmlStream,
                   InputStream xslStream,
                   com.aspose.ms.System.Xml.XmlReaderSettings settings)

        Bind xml/xsl to document

        Parameters:
        xmlStream - The xml stream.
        xslStream - The xsl stream if XSLT is used.
        settings - The xml reader settings.
      • getXmpMetadata

        public void getXmpMetadata(OutputStream output)

        Get XMP metadata from document.

        Specified by:
        getXmpMetadata in interface IDocument
        Parameters:
        output - Stream where metadata will be stored.
      • setXmpMetadata

        public void setXmpMetadata(InputStream stream)

        Set XMP metadata of document.

        Specified by:
        setXmpMetadata in interface IDocument
        Parameters:
        stream - Stream which contains XMP metadata.
      • getEnableObjectUnload

        public boolean getEnableObjectUnload()

        Get or sets flag which enables document partially be unloaded from memory. This allow to decrease memory usage but may have negative effect on perofmance.

        Returns:
        boolean value
      • setEnableObjectUnload

        public void setEnableObjectUnload(boolean value)

        Get or sets flag which enables document partially be unloaded from memory. This allow to decrease memory usage but may have negative effect on perofmance.

        Parameters:
        value - boolean value