PdfDocument Class
Represents a pdf document where a watermark can be placed.
Inheritance Hierarchy

Namespace: GroupDocs.Watermark.Pdf
Assembly: GroupDocs.Watermark (in GroupDocs.Watermark.dll) Version: 19.5
Syntax
public class PdfDocument : Document

The PdfDocument type exposes the following members.

Properties
  NameDescription
Public propertyAttachments
Gets the collection of all attachments of this PdfDocument.
Public propertyPageMarginType
Gets or sets pdf page margins to be used during watermark adding. This property works only when ConsiderParentMargins is set to true. If ConsiderParentMargins is false, when pdf CropBox is used as watermarking area.
Public propertyCode examplePages
Gets the collection of all pages of this PdfDocument.
Public propertyCode exampleSearchableObjects
Gets or sets the document objects that are to be included in a watermark search. Note, this property also specifies document objects which are used in image search. For more information see FindWatermarks, FindWatermarks(SearchCriteria), FindImages and FindImages(ImageSearchCriteria) methods.
(Inherited from Document.)
Methods
  NameDescription
Public methodAddAnnotationWatermark(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).
Public methodAddAnnotationWatermark(Watermark, Boolean)
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).
Public methodAddArtifactWatermark
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).
Public methodCode exampleAddWatermark
Adds a watermark to this DocumentPart.
(Inherited from DocumentPart.)
Public methodDecrypt
Decrypts the document.
Public methodDispose
Disposes the current instance.
(Inherited from Document.)
Protected methodDispose(Boolean)
Releases all resources used by the PdfDocument
(Overrides DocumentDispose(Boolean).)
Public methodEncrypt(String)
Encrypts the document using the same password as user password and owner password.
Public methodEncrypt(String, String, PdfPermissions, PdfCryptoAlgorithm)
Encrypts the document.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodCode exampleFindImages
Finds all images in the document. The search is conducted in objects specified in SearchableObjects.
(Inherited from DocumentPart.)
Public methodFindImages(ImageSearchCriteria)
Finds images according to specified search criteria. The search is conducted in objects specified in SearchableObjects.
(Inherited from DocumentPart.)
Public methodFindWatermarks
Finds all possible watermarks in the document. The search is conducted in objects specified in SearchableObjects.
(Inherited from DocumentPart.)
Public methodCode exampleFindWatermarks(SearchCriteria)
Finds possible watermarks according to specified search criteria. The search is conducted in objects specified in SearchableObjects.
(Inherited from DocumentPart.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRasterize
Converts all document pages into images.
Public methodSave
Saves the document to the underlying stream.
(Overrides DocumentSave.)
Public methodSave(Stream)
Saves the document to the specified stream.
(Inherited from Document.)
Public methodSave(String)
Saves the document to the specified file location.
(Inherited from Document.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Examples
Load and save PDF document of any supported version.
C#
using (PdfDocument document = Document.Load<PdfDocument>(@"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");
}
See Also