com.groupdocs.watermark

Interfaces

Classes

Exceptions

com.groupdocs.watermark

Class PdfDocument

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


    public class PdfDocument
    extends Document

    Represents a pdf document where a watermark can be placed.

    This example demonstrates how to load and save PDF document of any supported version.

    PdfDocument document = Document.load(PdfDocument.class, "D:\\input.pdf");
     // Use addWatermark method to add watermark to all pages.
     // Use the collection of pages to add watermark to a particular page.
     // Save changes.
     document.save("D:\\output.pdf");
     document.close();
     
    • Method Detail

      • getPages

        public final PdfPageCollection getPages()

        Gets the collection of all pages of this PdfDocument.

        Returns:
        The collection of all pages of this PdfDocument.

        This example demonstrates how to add watermark to a particular page.

        PdfDocument document = Document.load(PdfDocument.class, "D:\\input.pdf");
         // Initialize text or image watermark.
         TextWatermark watermark = new TextWatermark("DRAFT", new Font("Arial", 19));
         // Add watermark to a particular page.
         document.getPages().get_Item(0).addWatermark(watermark);
         // Save changes.
         document.save("D:\\output.pdf");
         document.close();
         
      • getAttachments

        public final PdfAttachmentCollection getAttachments()

        Gets the collection of all attachments of this PdfDocument.

        Returns:
        The collection of all attachments of this PdfDocument.
      • getPageMarginType

        public final int getPageMarginType()

        Gets pdf page margins to be used during watermark adding. This property works only when GroupDocs.Watermark.Watermark.ConsiderParentMargins is set to true. If GroupDocs.Watermark.Watermark.ConsiderParentMargins is false, when pdf CropBox is used as watermarking area.

        Returns:
        Pdf page margins to be used during watermark adding. The default value is P:WatermarkingPageMargins.TrimBox.
      • setPageMarginType

        public final void setPageMarginType(int value)

        Sets pdf page margins to be used during watermark adding. This property works only when GroupDocs.Watermark.Watermark.ConsiderParentMargins is set to true. If GroupDocs.Watermark.Watermark.ConsiderParentMargins is false, when pdf CropBox is used as watermarking area.

        Parameters:
        value - Pdf page margins to be used during watermark adding. The default value is P:WatermarkingPageMargins.TrimBox.
      • addArtifactWatermark

        public final void addArtifactWatermark(Watermark watermark)

        Adds an artifact watermark to all pages of this PdfDocument. This method assumes that watermark offset and size are measured in points (if they are assigned).

        Parameters:
        watermark - The watermark to add to the document.
      • addAnnotationWatermark

        public final void addAnnotationWatermark(Watermark watermark,
                                  boolean isPrintOnly)

        Adds an annotation watermark to all pages of this PdfDocument. This method assumes that watermark offset and size are measured in points (if they are assigned).

        Parameters:
        watermark - The watermark to add to the document.
        isPrintOnly - The value indicating whether annotation will be printed, but not displayed in pdf viewing application.
      • addAnnotationWatermark

        public final void addAnnotationWatermark(Watermark watermark)

        Adds an annotation watermark to all pages of this PdfDocument. This method assumes that watermark offset and size are measured in points (if they are assigned).

        Parameters:
        watermark - The watermark to add to the document.
      • encrypt

        public final void encrypt(String password)

        Encrypts the document using the same password as user password and owner password.

        Parameters:
        password - User and owner password.
      • encrypt

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

        Encrypts the document.

        Parameters:
        userPassword - User password.
        ownerPassword - Owner password.
        permissions - Document permissions.
        cryptoAlgorithm - Cryptographic algorithm.
      • decrypt

        public final void decrypt()

        Decrypts the document.

      • rasterize

        public final void rasterize(int horizontalResolution,
                     int verticalResolution,
                     int imageFormat)

        Converts all document pages into images.

        Parameters:
        horizontalResolution - Horizontal image resolution.
        verticalResolution - Vertical image resolution.
        imageFormat - Image format.
      • dispose

        protected void dispose(boolean disposing)

        Releases all resources used by the PdfDocument

        Overrides:
        dispose in class Document
        Parameters:
        disposing - True to release both managed and unmanaged resources; false to release only unmanaged resources.