A digital watermark is any auxiliary data embedded into a document used for subsequent identification. Watermarks may provide contextual support to an author's content, but are otherwise independent of that content. For example, stamping a page as "DRAFT" or "CONFIDENTIAL" imparts meaning beyond any text or drawings present on that page.
PDF documents may express a digital watermark using any of the following techniques:
Each of these techniques can be accomplished using ImageGear, with varying complexity and completeness. See the following subsections:
Annotations are added to PDF pages by using the ImageGear.ART namespace, which supports a subset of available PDF annotations. Refer to PDF Annotations for the mapping used with PDF annotations.
ImageGear .NET does not export ART Marks to PDF Watermark annotations. Apps that require explicit PDF Watermark annotation support may use the basic object classes to create a PDF Watermark annotation object and appearance streams, as outlined in the PDF Reference under topic "Watermark Annotations".
The following sample code demonstrates creating a Text ART mark and exporting to a PDF page as a FreeText annotation:
Refer to the AddWatermarkToPDFPage sample. See Samples and Demos.
See the PDF Reference topic "Annotations" for additional information.
Watermarks expressed as PDF page graphics are added using the ImageGear.Formats.PDF namespace. This namespace provides classes for content editing modeled after graphics objects and operators described in the PDF Reference.
The following snippet demonstrates placing a 24-bpp RGB bitmap at the bottom left corner of a PDF page:
Adjustments are required to successfully add images utilizing other pixel formats and color spaces in accordance to the image XObject discussion in the PDF reference.
Refer to the AddWatermarkToPDFPage sample. See Samples and Demos.
See the PDF Reference topic "Graphics" for additional information.
See ImGearPDFFixedMatrix Class for information about defining a transformation matrix.
Watermark optional content can be added to PDF pages using the ImageGear.Formats.PDF namespace, which provides classes for layer management.
Refer to Containers, Dictionaries, and Layers for guidance on using the ImageGear.Formats.PDF namespace to manage watermarks with Optional Content Groups (OCG).
To designate a watermark intended for printing, add an Optional Content Print Usage dictionary with Subtype name "Watermark" to that OCG, represented with an ImGearPDFLayer object:
C# |
Copy Code |
---|---|
// Create Print Usage dictionary ImGearPDFBasDict igPrintUsageDict = new ImGearPDFBasDict( igPDFDocument, false, 2 ); igPrintUsageDict.PutName( new ImGearPDFAtom("Subtype"), false, new ImGearPDFAtom( "Watermark" )); igPrintUsageDict.PutName( new ImGearPDFAtom("PrintState"), false, new ImGearPDFAtom( "ON" )); // Add Print Usage dictionary to OCG group named "WatermarkLayer" ImGearPDFLayer igWatermarkLayer = igPDFDocument.CreateLayer( "WatermarkLayer" ); igWatermarkLayer.SetUsageInfo( new ImGearPDFAtom("Print"), igPrintUsageDict ); |
See the PDF Reference topic "Making Graphical Content Optional" for additional information.
Watermarks expressed as Pagination Artifacts can be added using the ImageGear.Formats.PDF namespace, which provides classes to create a marked-content sequence in accordance with the PDF Reference.
This usage is not demonstrated in any sample presently.
See the PDF Reference topic "Real Content and Artifacts" for additional information.