com.aspose.pdf

Interfaces

Classes

Enums

Exceptions

com.aspose.pdf

Interface IDocument

  • All Superinterfaces:
    com.aspose.ms.System.IDisposable
    All Known Implementing Classes:
    Document, DocumentWeb


    public interface IDocument
    extends com.aspose.ms.System.IDisposable

    interface representing PDF document

    • Method Detail

      • isPdfaCompliant

        boolean isPdfaCompliant()
      • getDestinations

        DestinationCollection getDestinations()

        Gets the collection of destinations.

        Returns:
        DestinationCollection object
      • getPdfaFormat

        int getPdfaFormat()
        Returns:
        PdfFormat element
        See Also:
        PdfFormat
      • removePdfaCompliance

        void removePdfaCompliance()

        Remove pdfa compliance from the document

      • getCollection

        Collection getCollection()

        Gets collection of document.

        Returns:
        Collection object
      • setCollection

        void setCollection(Collection value)
        Sets collection of document.
        Parameters:
        value - Collection object
      • getEngineDoc

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

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

        Returns:
        IPdfDocument object
      • getVersion

        String getVersion()

        Gets a version of Pdf from Pdf file header.

        Returns:
        String object
      • getOpenAction

        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 object
      • setOpenAction

        void setOpenAction(IAppointment value)

        Sets action performed at document opening.

        Parameters:
        value - IAppointment object
      • getOptimizeSize

        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 value
      • setOptimizeSize

        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:
        value - boolean value
      • getIgnoreCorruptedObjects

        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 value
      • setIgnoreCorruptedObjects

        void setIgnoreCorruptedObjects(boolean value)
      • getCatalogValue

        Object getCatalogValue(String key)

        Returns item value from catalog dictionary.

        Parameters:
        key - The key of item.
        Returns:
        Item value - if key was successfully found; otherwise, null.
      • getHideToolBar

        boolean getHideToolBar()

        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.getHideToolBar();
         
        Returns:
        boolean value
      • setHideToolBar

        void setHideToolBar(boolean value)

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

        Parameters:
        value - boolean value
      • getHideMenubar

        boolean getHideMenubar()

        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.getHideMenubar();
         
        Returns:
        boolean value
      • setHideMenubar

        void setHideMenubar(boolean value)

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

        Parameters:
        value - boolean value
      • getHideWindowUI

        boolean getHideWindowUI()

        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.getHideWindowUI();
         
        Returns:
        boolean value
      • setHideWindowUI

        void setHideWindowUI(boolean value)

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

        Parameters:
        value - boolean value
      • getFitWindow

        boolean getFitWindow()

        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.getFitWindow();
         
        Returns:
        boolean value
      • setFitWindow

        void setFitWindow(boolean value)

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

        Parameters:
        value - boolean value
      • getCenterWindow

        boolean getCenterWindow()

        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.getCenterWindow();
         
        Returns:
        boolean value
      • setCenterWindow

        void setCenterWindow(boolean value)

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

        Parameters:
        value - boolean value
      • getDisplayDocTitle

        boolean getDisplayDocTitle()

        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.getDisplayDocTitle();
         
        Returns:
        boolean value
      • setDisplayDocTitle

        void setDisplayDocTitle(boolean value)

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

        Parameters:
        value - boolean value
      • getPages

        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:
        boolean value
      • getOutlines

        OutlineCollection getOutlines()

        Gets document outlines.

        Returns:
        OutlineCollection object
      • getActions

        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 object
      • getForm

        Form getForm()

        Gets Acro Form of the document.

        Returns:
        Form object
      • getEmbeddedFiles

        EmbeddedFileCollection getEmbeddedFiles()

        Gets collection of files embedded to document.

        Returns:
        EmbeddedFileCollection object
      • getDirection

        int getDirection()

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

        Returns:
        Direction element
        See Also:
        Direction
      • setDirection

        void setDirection(int value)

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

        Parameters:
        value - Direction element
        See Also:
        Direction
      • getPageMode

        int getPageMode()

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

        Returns:
        PageMode element
        See Also:
        PageMode
      • setPageMode

        void setPageMode(int value)

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

        Parameters:
        value - PageMode element
        See Also:
        PageMode
      • getNonFullScreenPageMode

        int getNonFullScreenPageMode()

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

        Returns:
        PageMode element
        See Also:
        PageMode
      • setNonFullScreenPageMode

        void setNonFullScreenPageMode(int value)

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

        Parameters:
        value - PageMode element
        See Also:
        PageMode
      • getPageLayout

        int getPageLayout()

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

        Returns:
        PageLayout element
        See Also:
        PageLayout
      • setPageLayout

        void setPageLayout(int value)

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

        Parameters:
        value - PageLayout element
        See Also:
        PageLayout
      • getDuplex

        int getDuplex()

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

        Returns:
        PrintDuplex element
        See Also:
        PrintDuplex
      • setDuplex

        void setDuplex(int value)

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

        Parameters:
        value - PrintDuplex element
        See Also:
        PrintDuplex
      • getFileName

        String getFileName()

        Name of the PDF file that caused this document

        Returns:
        String object
      • setLayersAdded

        void setLayersAdded(boolean value)
        Set LayersAdded value
        Parameters:
        value - boolean value
      • getPageInfo

        PageInfo getPageInfo()
        Gets the page info.(for generator only)
        Returns:
        The page info.
      • setPageInfo

        void setPageInfo(PageInfo value)
        Sets the page info.(for generator only)
        Parameters:
        value - PageInfo object
      • getInfo

        DocumentInfo getInfo()

        Gets document info.

        Returns:
        DocumentInfo object
      • getMetadata

        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 object
      • getLogicalStructure

        RootElement getLogicalStructure()

        Gets logical structure of the document.

        Returns:
        RootElement object
      • processParagraphs

        void processParagraphs()

        Stores document into stream.

      • save

        void save(OutputStream output)

        Stores document into stream.

        Parameters:
        output - Stream where document shell be stored.
      • save

        void save(String outputFileName)

        Saves document into the specified file.

        Parameters:
        outputFileName - Path to file where the document will be stored.
      • save

        void save(com.aspose.ms.System.IO.FileStream output)
        Internal method
        Parameters:
        output - intermal object.
      • exportAnnotationsToXfdf

        void exportAnnotationsToXfdf(String fileName)

        Exports all document annotations to XFDF file

        Parameters:
        fileName - XFDF file name
      • sendTo

        void sendTo(DocumentDevice device,
                    OutputStream output)

        Sends the whole document to the document device for processing.

        Parameters:
        device - DocumentDevice object
        output - OutputStream object
      • sendTo

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

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

        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

        void sendTo(DocumentDevice device,
                    String outputFileName)

        Sends the whole document to the document device for processing.

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

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

        Sends the whole document to the document device for processing.

        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

        void removeMetadata()

        Removes metadata from the document.

      • importAnnotationsFromXfdf

        void importAnnotationsFromXfdf(String fileName)

        Imports annotations from XFDF file to document.

        Parameters:
        fileName - XFDF file name
      • validate

        boolean validate(String outputLogFileName,
                         int format)

        Validate document into the specified file.

        Parameters:
        outputLogFileName - Path to file where the comments will be stored.
        format - Pdf format.
        Returns:
        boolean value
      • validate

        boolean validate(OutputStream outputLogStream,
                         int format)

        Validate document into the specified file.

        Parameters:
        outputLogStream - Stream where the comments will be stored.
        format - Pdf format.
        Returns:
        The operation result
        See Also:
        PdfFormat
      • convert

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

        Convert document and save errors into the specified file.

        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

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

        Convert document and save errors into the specified file.

        Parameters:
        outputLogFileName - Path to file where the comments will be stored.
        format - Pdf format.
        action - Action for objects that can not be converted
        Returns:
        The operation result
        See Also:
        PdfFormat, ConvertErrorAction
      • convert

        boolean convert(PdfFormatConversionOptions options)

        Convert document using specified conversion options

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

        boolean convert(Document.CallBackGetHocr callback)
        Convert document and save errors into the specified file.
        Parameters:
        callback - Action for objects that can not be converted
        Returns:
        The operation result
      • convert

        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:
        callback - Action for objects that can not be converted
        isTestVisible - boolean value
        Returns:
        The operation result
      • convert

        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:
        callback - Action for objects that can not be converted
        isTestVisible - boolean value
        isOriginalImage - boolean value
        Returns:
        The operation result
      • convert

        boolean convert(OutputStream outputLogStream,
                        int format,
                        int action)
      • flatten

        void flatten()

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

      • getCryptoAlgorithm

        int getCryptoAlgorithm()

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

        Returns:
        int value
      • encrypt

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

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

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

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

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

        Parameters:
        userPassword - User password.
        ownerPassword - Owner password.
        permissions - Document permissions, see Permissions for details.
        cryptoAlgorithm - Cryptographic algorithm, see CryptoAlgorithm for details.
      • encrypt

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

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

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

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

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

        Parameters:
        ownerPassword - Owner password.
        newUserPassword - New user password.
        newOwnerPassword - New owner password.
      • isLinearized

        boolean isLinearized()

        Gets or sets a value indicating whether document is linearized.

        Returns:
        boolean value
      • setLinearized

        void setLinearized(boolean value)

        Sets a value indicating whether document is linearized.

        Parameters:
        value - boolean value
      • decrypt

        void decrypt()

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

      • getPermissions

        int getPermissions()

        Gets permissions of the document.

        Returns:
        int value
      • isEncrypted

        boolean isEncrypted()

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

        Returns:
        boolean value
      • optimize

        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

        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 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();

      • save

        void save(OutputStream outputStream,
                  int format)
        Save document
        Parameters:
        outputStream - OutputStream object
        format - SaveFormat value
        See Also:
        SaveFormat
      • save

        void save(String outputFileName,
                  SaveOptions options)

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

        Parameters:
        outputFileName - Path to file where the document will be stored.
        options - Save options.
      • save

        void save(OutputStream outputStream,
                  SaveOptions options)

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

        Parameters:
        outputStream - OutputStream where the document will be stored.
        options - Save options.
      • getId

        Id getId()

        Gets the ID.

        Returns:
        Id object
      • getMetadataStream

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

        Returns raw metadata stream

        Returns:
        IPdfStreamAccessor object
      • updatePages

        void updatePages()
        updatePages
      • suppressUpdate

        void suppressUpdate()
        suppressUpdate
      • resumeUpdate

        void resumeUpdate()
        resumeUpdate
      • dispose

        void dispose()

        Closes all resources used by this document.

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

        Color getBackground()

        Gets the background color of the document.

        Returns:
        java.awt.Color object
      • setBackground

        void setBackground(Color value)

        Sets the background color of the document.

        Parameters:
        value - java.awt.Color object
      • getDefaultCopier

        Copier getDefaultCopier()

        Returns copier used for coping pages to this document.

        Returns:
        Copier object
      • optimizeResources

        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

        void optimizeResources(Document.OptimizationOptions strategy)

        Optimize resources in the document according to defined optimization strategy.

        Parameters:
        strategy - Optimization strategy.
      • getPageLabels

        PageLabelCollection getPageLabels()
        Gets page labels in the document.
        Returns:
        PageLabelCollection object
      • freeMemory

        void freeMemory()

        Clears memory

      • afterImport

        void afterImport()

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

      • saveXml

        void saveXml(String file)

        Save document to XML.

        Parameters:
        file - The document model xml file
      • bindXml

        void bindXml(String xmlFile,
                     String xslFile)

        Bind xml/xsl to document

        Parameters:
        xmlFile - The xml file.
        xslFile - The xsl file if XSLT is used.
      • getObjectById

        Object getObjectById(String id)

        Gets a object with specified ID in the document.

        Parameters:
        id - The object id.
        Returns:
        The object with specified id. Null if the id is not found.
      • bindXml

        void bindXml(String file)

        Bind xml to document

        Parameters:
        file - The xml file
      • repair

        void repair()
        Repairs broken document.
      • getEmbedStandardFonts

        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 value
      • setEmbedStandardFonts

        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:
        value - boolean value
      • convertInternal

        boolean convertInternal(com.aspose.ms.System.IO.Stream log,
                                int _convertTo,
                                int none)
        Internal method
        Parameters:
        log - Internal object
        _convertTo - Internal object
        none - Internal object
        Returns:
        Internal value
      • saveInternal

        void saveInternal(com.aspose.ms.System.IO.Stream destStream)
        Internal method
        Parameters:
        destStream - Internal object
      • getXmpMetadata

        void getXmpMetadata(OutputStream stream)

        Get XMP metadata from document.

        Parameters:
        stream - Stream where metadata will be stored.
      • setXmpMetadata

        void setXmpMetadata(InputStream stream)

        Set XMP metadata of document.

        Parameters:
        stream - Stream which contains XMP metadata.
      • isAbsentFontTryToSubstitute

        boolean isAbsentFontTryToSubstitute()
        Notification about missing fonts when processing documents
        Returns:
        boolean value
      • setAbsentFontTryToSubstitute

        void setAbsentFontTryToSubstitute(boolean setAbsentFontTryToSubstitute)
        Setting flag for set program determined font in case of absence font.
        Parameters:
        setAbsentFontTryToSubstitute - boolean value
      • isXrefGapsAllowed

        boolean isXrefGapsAllowed()

        Gets or sets the is document pdfa compliant.

        Returns:
        boolean value
      • setXrefGapsAllowed

        void setXrefGapsAllowed(boolean value)

        Gets or sets the is document pdfa compliant.

        Parameters:
        value - boolean value
      • check

        boolean check(boolean doRepair)
        Validates document.
        Parameters:
        doRepair - If true found issues will be repaired.
        Returns:
        boolean value