Comprehensive Guide for Developers: Features, Integration, and API Reference
The PDF Stamper API. More...
Go to the source code of this file.
Macros | |
| #define | PDF_STAMPER_API PDFSDK_IMPORT_ |
Typedefs | |
| typedef struct PDFStamperRec_ * | PDFStamper |
| The opaque handle to the PDFStamper object. | |
Enumerations | |
| enum | PDFStampSizeMode { kPDFStampSizeRelative = 1 , kPDFStampSizeAbsolute = 2 , kPDFStampSizeFontSize = 3 } |
| Specifies how a stamp is sized. More... | |
| enum | PDFStampHAlign { kPDFStampHAlignLeft = -1 , kPDFStampHAlignCenter = 0 , kPDFStampHAlignRight = 1 } |
| Horizontal alignment of the stamp relative to the crop box. | |
| enum | PDFStampVAlign { kPDFStampVAlignBottom = -1 , kPDFStampVAlignCenter = 0 , kPDFStampVAlignTop = 1 } |
| Vertical alignment of the stamp relative to the crop box. | |
| enum | PDFStampTextAlign { kPDFStampTextAlignLeft = -1 , kPDFStampTextAlignCenter = 0 , kPDFStampTextAlignRight = 1 } |
| Alignment of multi-line text within a text stamp. | |
Functions | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperCreate (PDFStampSizeMode sizeMode, float a, float b, PDFStamper *pStamper) |
| Creates a new PDFStamper object with an initial size. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetSize (PDFStamper stamper, PDFStampSizeMode sizeMode, float a, float b) |
| Sets how the stamp is sized. Overrides the value passed to PDFStamperCreate. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetPosition (PDFStamper stamper, float horizontalDistance, float verticalDistance, bool usePercentage) |
| Sets the offset of the stamp from the alignment anchor. Default is no offset (0, 0). | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetAlignment (PDFStamper stamper, PDFStampHAlign hAlign, PDFStampVAlign vAlign) |
| Sets the anchor that the position offset is measured from. Default is centered (kPDFStampHAlignCenter, kPDFStampVAlignCenter). | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetRotation (PDFStamper stamper, float degrees) |
| Sets the rotation of the stamp, in degrees, counter-clockwise. Default is 0 (no rotation). | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetOpacity (PDFStamper stamper, float opacity) |
| Sets the opacity of the stamp. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetAsBackground (PDFStamper stamper, bool background) |
| Specifies whether the stamp is placed behind the page content (background) or on top (foreground). Default is on top (foreground). | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetAsAnnotation (PDFStamper stamper, bool annotation) |
| Specifies whether the stamp is added as a Stamp annotation instead of page content. Default is page content. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperShowsOnScreen (PDFStamper stamper, bool onScreen) |
| Specifies whether the stamp is visible on screen. Default is true. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperShowsOnPrint (PDFStamper stamper, bool onPrint) |
| Specifies whether the stamp is visible when the document is printed. Default is true. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperShowsInLayersPanel (PDFStamper stamper, bool inLayersPanel) |
| Specifies whether the stamp's optional-content layer is registered in the document's layer order (/Order) so it appears in a viewer's layers panel. Default is false. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetName (PDFStamper stamper, const wchar_t *name) |
| Sets the stamp name. Default is "Stamp". | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetFont (PDFStamper stamper, const PDFontInfo *fontInfo) |
| Sets the font used for text stamps. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetFontColor (PDFStamper stamper, PDColorValue color) |
| Sets the color used for text stamps. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetTextOutline (PDFStamper stamper, PDColorValue strokeColor, float strokeWidth) |
| Gives text stamps an outline (stroke), in addition to or instead of the fill. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperSetTextAlignment (PDFStamper stamper, PDFStampTextAlign textAlign) |
| Sets the alignment of multi-line text within a text stamp. Default is kPDFStampTextAlignLeft. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperStampText (PDFStamper stamper, PDDoc destDoc, const wchar_t *text, const PDPageRange *destPages) |
| Stamps text onto the given pages using the configured font, color and text alignment. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperStampImage (PDFStamper stamper, PDDoc destDoc, GXBitmap bitmap, const PDPageRange *destPages) |
| Stamps a raster image from an in-memory bitmap onto the given pages. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperStampImageFromFile (PDFStamper stamper, PDDoc destDoc, const wchar_t *imagePath, const PDPageRange *destPages) |
| Stamps a raster image loaded from a file onto the given pages. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperStampPage (PDFStamper stamper, PDDoc destDoc, PDDoc srcDoc, size_t srcPageIndex, const PDPageRange *destPages) |
| Stamps a single page from a source PDF document (as vector art) onto the given pages. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperHasStamps (PDDoc doc, const PDPageRange *pages, bool *pHasStamps) |
| Reports whether any of the given pages contains at least one stamp. | |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV | PDFStamperDeleteStamps (PDDoc doc, const PDPageRange *pages) |
| Deletes all stamps from the given pages. | |
The PDF Stamper API.
The PDF Stamper API stamps PDF pages with text, raster images or vector art (another PDF page) in a few calls. A Stamper is a configuration object: set the size, position, alignment, rotation and opacity once, then call one of the Stamp* functions repeatedly to apply the stamp to a set of pages.
Stamped content is wrapped in a standard PDF marked-content artifact (/Artifact with /Type /Pagination and /Subtype /Watermark) so that it can be located and removed later via PDFStamperHasStamps and PDFStamperDeleteStamps.
For full control over PDF content creation use the Element/Content API instead.
| typedef struct PDFStamperRec_* PDFStamper |
The opaque handle to the PDFStamper object.
| enum PDFStampSizeMode |
Specifies how a stamp is sized.
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperCreate | ( | PDFStampSizeMode | sizeMode, |
| float | a, | ||
| float | b, | ||
| PDFStamper * | pStamper ) |
Creates a new PDFStamper object with an initial size.
| [in] | sizeMode | How the stamp is sized. |
| [in] | a | The horizontal size component. Meaning depends on sizeMode. |
| [in] | b | The vertical size component. Meaning depends on sizeMode. |
| [out] | pStamper | A pointer to a variable that receives the new PDFStamper object. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperDeleteStamps | ( | PDDoc | doc, |
| const PDPageRange * | pages ) |
Deletes all stamps from the given pages.
| [in] | doc | The document to delete stamps from. |
| [in] | pages | The pages to delete stamps from. Pass NULL for all pages. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperHasStamps | ( | PDDoc | doc, |
| const PDPageRange * | pages, | ||
| bool * | pHasStamps ) |
Reports whether any of the given pages contains at least one stamp.
| [in] | doc | The document to check. |
| [in] | pages | The pages to check. Pass NULL to check all pages. |
| [out] | pHasStamps | Receives true if at least one stamp is found. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetAlignment | ( | PDFStamper | stamper, |
| PDFStampHAlign | hAlign, | ||
| PDFStampVAlign | vAlign ) |
Sets the anchor that the position offset is measured from. Default is centered (kPDFStampHAlignCenter, kPDFStampVAlignCenter).
| [in] | stamper | The PDFStamper object. |
| [in] | hAlign | Horizontal anchor. |
| [in] | vAlign | Vertical anchor. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetAsAnnotation | ( | PDFStamper | stamper, |
| bool | annotation ) |
Specifies whether the stamp is added as a Stamp annotation instead of page content. Default is page content.
Annotation stamps are not affected by SetAsBackground and are not found or removed by PDFStamperHasStamps / PDFStamperDeleteStamps.
| [in] | stamper | The PDFStamper object. |
| [in] | annotation | If true, the stamp is added as a Stamp annotation; otherwise into the page content. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetAsBackground | ( | PDFStamper | stamper, |
| bool | background ) |
Specifies whether the stamp is placed behind the page content (background) or on top (foreground). Default is on top (foreground).
| [in] | stamper | The PDFStamper object. |
| [in] | background | If true, the stamp is inserted as a background layer; otherwise on top. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetFont | ( | PDFStamper | stamper, |
| const PDFontInfo * | fontInfo ) |
Sets the font used for text stamps.
| [in] | stamper | The PDFStamper object. |
| [in] | fontInfo | The font description (family, format, style). |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetFontColor | ( | PDFStamper | stamper, |
| PDColorValue | color ) |
Sets the color used for text stamps.
| [in] | stamper | The PDFStamper object. |
| [in] | color | The font color. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetName | ( | PDFStamper | stamper, |
| const wchar_t * | name ) |
Sets the stamp name. Default is "Stamp".
Used as the annotation title for annotation stamps, and as the optional content layer name for content stamps whose screen/print visibility is restricted.
| [in] | stamper | The PDFStamper object. |
| [in] | name | The name, in wide character string format. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetOpacity | ( | PDFStamper | stamper, |
| float | opacity ) |
Sets the opacity of the stamp.
| [in] | stamper | The PDFStamper object. |
| [in] | opacity | The opacity in the range [0, 1], where 1 is fully opaque. Default is 1. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetPosition | ( | PDFStamper | stamper, |
| float | horizontalDistance, | ||
| float | verticalDistance, | ||
| bool | usePercentage ) |
Sets the offset of the stamp from the alignment anchor. Default is no offset (0, 0).
| [in] | stamper | The PDFStamper object. |
| [in] | horizontalDistance | Horizontal offset from the left/right/center anchor. |
| [in] | verticalDistance | Vertical offset from the top/bottom/center anchor. |
| [in] | usePercentage | If true, the distances are fractions of the crop box width/height; if false, they are measured in points. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetRotation | ( | PDFStamper | stamper, |
| float | degrees ) |
Sets the rotation of the stamp, in degrees, counter-clockwise. Default is 0 (no rotation).
| [in] | stamper | The PDFStamper object. |
| [in] | degrees | The rotation in degrees. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetSize | ( | PDFStamper | stamper, |
| PDFStampSizeMode | sizeMode, | ||
| float | a, | ||
| float | b ) |
Sets how the stamp is sized. Overrides the value passed to PDFStamperCreate.
| [in] | stamper | The PDFStamper object. |
| [in] | sizeMode | How the stamp is sized. |
| [in] | a | The horizontal size component. Meaning depends on sizeMode. |
| [in] | b | The vertical size component. Meaning depends on sizeMode. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetTextAlignment | ( | PDFStamper | stamper, |
| PDFStampTextAlign | textAlign ) |
Sets the alignment of multi-line text within a text stamp. Default is kPDFStampTextAlignLeft.
| [in] | stamper | The PDFStamper object. |
| [in] | textAlign | The text alignment. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetTextOutline | ( | PDFStamper | stamper, |
| PDColorValue | strokeColor, | ||
| float | strokeWidth ) |
Gives text stamps an outline (stroke), in addition to or instead of the fill.
| [in] | stamper | The PDFStamper object. |
| [in] | strokeColor | The outline (stroke) color, or kPDColorNone to disable the outline (fill only). |
| [in] | strokeWidth | The outline (stroke) width, in the stamp's coordinate space. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperShowsInLayersPanel | ( | PDFStamper | stamper, |
| bool | inLayersPanel ) |
Specifies whether the stamp's optional-content layer is registered in the document's layer order (/Order) so it appears in a viewer's layers panel. Default is false.
| [in] | stamper | The PDFStamper object. |
| [in] | inLayersPanel | If true, the created layer is added to the configuration's /Order. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperShowsOnPrint | ( | PDFStamper | stamper, |
| bool | onPrint ) |
Specifies whether the stamp is visible when the document is printed. Default is true.
| [in] | stamper | The PDFStamper object. |
| [in] | onPrint | If true, the stamp is printed. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperShowsOnScreen | ( | PDFStamper | stamper, |
| bool | onScreen ) |
Specifies whether the stamp is visible on screen. Default is true.
| [in] | stamper | The PDFStamper object. |
| [in] | onScreen | If true, the stamp is shown on screen. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperStampImage | ( | PDFStamper | stamper, |
| PDDoc | destDoc, | ||
| GXBitmap | bitmap, | ||
| const PDPageRange * | destPages ) |
Stamps a raster image from an in-memory bitmap onto the given pages.
| [in] | stamper | The PDFStamper object. |
| [in] | destDoc | The document being stamped. |
| [in] | bitmap | The image bitmap to stamp. |
| [in] | destPages | The pages to stamp. Pass NULL to stamp all pages. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperStampImageFromFile | ( | PDFStamper | stamper, |
| PDDoc | destDoc, | ||
| const wchar_t * | imagePath, | ||
| const PDPageRange * | destPages ) |
Stamps a raster image loaded from a file onto the given pages.
| [in] | stamper | The PDFStamper object. |
| [in] | destDoc | The document being stamped. |
| [in] | imagePath | The path to the image file (.png .jpg .bmp .gif etc.). |
| [in] | destPages | The pages to stamp. Pass NULL to stamp all pages. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperStampPage | ( | PDFStamper | stamper, |
| PDDoc | destDoc, | ||
| PDDoc | srcDoc, | ||
| size_t | srcPageIndex, | ||
| const PDPageRange * | destPages ) |
Stamps a single page from a source PDF document (as vector art) onto the given pages.
| [in] | stamper | The PDFStamper object. |
| [in] | destDoc | The document being stamped. |
| [in] | srcDoc | The source PDF document that contains the page to stamp. |
| [in] | srcPageIndex | The zero-based index of the source page in srcDoc. |
| [in] | destPages | The pages to stamp. Pass NULL to stamp all pages. |
| PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperStampText | ( | PDFStamper | stamper, |
| PDDoc | destDoc, | ||
| const wchar_t * | text, | ||
| const PDPageRange * | destPages ) |
Stamps text onto the given pages using the configured font, color and text alignment.
| [in] | stamper | The PDFStamper object. |
| [in] | destDoc | The document being stamped. |
| [in] | text | The text to stamp, in wide character string format. |
| [in] | destPages | The pages to stamp. Pass NULL to stamp all pages. |