3#ifndef PDFSDK_CXX_STAMPER_H_INCLUDED_
4#define PDFSDK_CXX_STAMPER_H_INCLUDED_
10#include <pdfsdk/cxx/document.h>
11#include <pdfsdk/cxx/graphics.h>
12#include <pdfsdk/cxx/wrapper_base.h>
27class Stamper :
public detail::RefCountedHandle<PDFStamper> {
52 void SetPosition(
float horizontalDistance,
float verticalDistance,
bool usePercentage =
false);
122 void SetName(
const std::wstring& name);
159 void StampText(
const Document& destDoc,
const std::wstring& text,
const std::vector<size_t>& destPages = {});
175 void StampImageFromFile(
const Document& destDoc,
const std::filesystem::path& imagePath,
const std::vector<size_t>& destPages = {});
184 void StampPage(
const Document& destDoc,
const Document& srcDoc,
size_t srcPageIndex,
const std::vector<size_t>& destPages = {});
193 static bool HasStamps(
const Document& doc,
const std::vector<size_t>& pages = {});
208inline PDPageRange MakePageRange(
const std::vector<size_t>& pages) {
209 return {pages.data(), pages.size()};
225 PDF_CHECK_SUCCESS_X(
PDFStamperSetPosition(m_handle, horizontalDistance, verticalDistance, usePercentage));
281 PDPageRange range = detail::MakePageRange(destPages);
282 const PDPageRange* rangePtr = destPages.empty() ? nullptr : ⦥
287 PDPageRange range = detail::MakePageRange(destPages);
288 const PDPageRange* rangePtr = destPages.empty() ? nullptr : ⦥
293 PDPageRange range = detail::MakePageRange(destPages);
294 const PDPageRange* rangePtr = destPages.empty() ? nullptr : ⦥
299 PDPageRange range = detail::MakePageRange(destPages);
300 const PDPageRange* rangePtr = destPages.empty() ? nullptr : ⦥
301 PDF_CHECK_SUCCESS_X(
PDFStamperStampPage(m_handle, destDoc.get(), srcDoc.get(), srcPageIndex, rangePtr));
306 const PDPageRange* rangePtr = pages.empty() ? nullptr : ⦥
307 bool hasStamps =
false;
314 const PDPageRange* rangePtr = pages.empty() ? nullptr : ⦥
Represents a PDF document.
Definition document.h:27
Represents a bitmap.
Definition graphics.h:69
Stamps PDF pages with text, raster images or another PDF page.
Definition stamper.h:27
static Stamper Create(PDFStampSizeMode sizeMode, float a, float b)
Creates a new Stamper with an initial size.
Definition stamper.h:214
void SetAlignment(PDFStampHAlign hAlign, PDFStampVAlign vAlign)
Sets the anchor that the position offset is measured from. Default is centered (kPDFStampHAlignCenter...
Definition stamper.h:228
void SetOpacity(float opacity)
Sets the opacity of the stamp.
Definition stamper.h:236
void StampImage(const Document &destDoc, const Graphics::Bitmap &bitmap, const std::vector< size_t > &destPages={})
Stamps a raster image from an in-memory bitmap onto the given pages.
Definition stamper.h:286
void SetSize(PDFStampSizeMode sizeMode, float a, float b)
Sets how the stamp is sized. Overrides the value passed to Create.
Definition stamper.h:220
void SetPosition(float horizontalDistance, float verticalDistance, bool usePercentage=false)
Sets the offset of the stamp from the alignment anchor. Default is no offset (0, 0).
Definition stamper.h:224
void SetName(const std::wstring &name)
Sets the stamp name. Default is "Stamp".
Definition stamper.h:260
void SetAsBackground(bool background)
Specifies whether the stamp is placed behind the page content (background) or on top....
Definition stamper.h:240
void ShowsOnPrint(bool onPrint)
Specifies whether the stamp is visible when the document is printed. Default is true.
Definition stamper.h:252
void SetTextAlignment(PDFStampTextAlign textAlign)
Sets the alignment of multi-line text within a text stamp. Default is kPDFStampTextAlignLeft.
Definition stamper.h:276
static bool HasStamps(const Document &doc, const std::vector< size_t > &pages={})
Reports whether any of the given pages contains at least one stamp.
Definition stamper.h:304
void StampText(const Document &destDoc, const std::wstring &text, const std::vector< size_t > &destPages={})
Stamps text onto the given pages using the configured font, color and text alignment.
Definition stamper.h:280
void SetRotation(float degrees)
Sets the rotation of the stamp, in degrees, counter-clockwise. Default is 0 (no rotation).
Definition stamper.h:232
void SetFont(const PDFontInfo &fontInfo)
Sets the font used for text stamps.
Definition stamper.h:264
static void DeleteStamps(const Document &doc, const std::vector< size_t > &pages={})
Deletes all stamps from the given pages.
Definition stamper.h:312
void StampPage(const Document &destDoc, const Document &srcDoc, size_t srcPageIndex, const std::vector< size_t > &destPages={})
Stamps a single page from a source PDF document (as vector art) onto the given pages.
Definition stamper.h:298
void ShowsOnScreen(bool onScreen)
Specifies whether the stamp is visible on screen. Default is true.
Definition stamper.h:248
void SetTextOutline(PDColorValue strokeColor, float strokeWidth)
Gives text stamps an outline (stroke), in addition to or instead of the fill.
Definition stamper.h:272
void SetFontColor(PDColorValue color)
Sets the color used for text stamps.
Definition stamper.h:268
void StampImageFromFile(const Document &destDoc, const std::filesystem::path &imagePath, const std::vector< size_t > &destPages={})
Stamps a raster image loaded from a file onto the given pages.
Definition stamper.h:292
void SetAsAnnotation(bool annotation)
Specifies whether the stamp is added as a Stamp annotation instead of page content....
Definition stamper.h:244
void ShowsInLayersPanel(bool inLayersPanel)
Specifies whether the stamp's optional-content layer is registered in the document's layer order (/Or...
Definition stamper.h:256
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 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 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 PDFStamperSetOpacity(PDFStamper stamper, float opacity)
Sets the opacity of the stamp.
PDFStampVAlign
Vertical alignment of the stamp relative to the crop box.
Definition stamper.h:70
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 PDFStamperShowsOnPrint(PDFStamper stamper, bool onPrint)
Specifies whether the stamp is visible when the document is printed. Default is true.
struct PDFStamperRec_ * PDFStamper
The opaque handle to the PDFStamper object.
Definition stamper.h:89
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetAsAnnotation(PDFStamper stamper, bool annotation)
Specifies whether the stamp is added as a Stamp annotation instead of page content....
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetFont(PDFStamper stamper, const PDFontInfo *fontInfo)
Sets the font used for text stamps.
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...
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 PDFStamperSetTextOutline(PDFStamper stamper, PDColorValue strokeColor, float strokeWidth)
Gives text stamps an outline (stroke), in addition to or instead of the fill.
PDFStampTextAlign
Alignment of multi-line text within a text stamp.
Definition stamper.h:79
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 PDFStamperShowsInLayersPanel(PDFStamper stamper, bool inLayersPanel)
Specifies whether the stamp's optional-content layer is registered in the document's layer order (/Or...
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperCreate(PDFStampSizeMode sizeMode, float a, float b, PDFStamper *pStamper)
Creates a new PDFStamper object with an initial size.
PDFStampSizeMode
Specifies how a stamp is sized.
Definition stamper.h:38
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetName(PDFStamper stamper, const wchar_t *name)
Sets the stamp name. Default is "Stamp".
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperSetFontColor(PDFStamper stamper, PDColorValue color)
Sets the color used for text stamps.
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)....
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 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 PDFStamperDeleteStamps(PDDoc doc, const PDPageRange *pages)
Deletes all stamps from the given pages.
PDFStampHAlign
Horizontal alignment of the stamp relative to the crop box.
Definition stamper.h:61
PDFSDK_IMPORT_ PDErrCode PDFSDK_CALLCONV PDFStamperShowsOnScreen(PDFStamper stamper, bool onScreen)
Specifies whether the stamp is visible on screen. Default is true.
Specifies the font information.
Definition fonts.h:36
Specifies a structure to define a set of pages.
Definition document.h:44