PDF Watermark

Definitions for PDF watermarks.
Definitions and functions in this module are included in fpdf_watermark_r.h and fpdf_watermark_w.h.
Module: PDFWatermark
License Identifier: PDFWatermark/All
Available License Right: Reading/Writing
For License Right Reading, see fpdf_watermark_r.h.
For License Right Writing, see fpdf_watermark_w.h.
More...

Classes

struct  FSPDF_WATERMARK
 Handle type to PDF watermark. More...
 
struct  FSPDF_WATERMARK_SETTINGS
 Structure for watermark settings. More...
 
struct  FSPDF_WATERMARK_TEXTPROPERTIES
 Structure for watermark text properties. More...
 

Functions

FS_RESULT FSPDF_Watermark_GetCount (FSCRT_PAGE page, FS_INT32 *count)
 Get count of watermarks in a specific page and it does not include the SDK trial watermark. More...
 
FS_RESULT FSPDF_Watermark_GetSize (FSPDF_WATERMARK watermark, FS_FLOAT *width, FS_FLOAT *height)
 Retrieve the size (width and height) of a specific watermark. More...
 
FS_RESULT FSPDF_Watermark_CreateFromText (FSCRT_DOCUMENT document, const FSCRT_BSTR *text, const FSPDF_WATERMARK_TEXTPROPERTIES *properties, const FSPDF_WATERMARK_SETTINGS *settings, FSPDF_WATERMARK *watermark)
 Create a text watermark. More...
 
FS_RESULT FSPDF_Watermark_CreateFromBitmap (FSCRT_DOCUMENT document, FSCRT_BITMAP bitmap, const FSPDF_WATERMARK_SETTINGS *settings, FSPDF_WATERMARK *watermark)
 Create a bitmap watermark. More...
 
FS_RESULT FSPDF_Watermark_CreateFromImage (FSCRT_DOCUMENT document, FSCRT_IMAGE image, const FSPDF_WATERMARK_SETTINGS *settings, FSPDF_WATERMARK *watermark)
 Create an image watermark. More...
 
FS_RESULT FSPDF_Watermark_CreateFromPage (FSCRT_DOCUMENT document, FSCRT_PAGE page, const FSPDF_WATERMARK_SETTINGS *settings, FSPDF_WATERMARK *watermark)
 Create a page watermark. More...
 
FS_RESULT FSPDF_Watermark_InsertToPage (FSPDF_WATERMARK watermark, FSCRT_PAGE page)
 Insert a watermark into a specific page. More...
 
FS_RESULT FSPDF_Watermark_Release (FSPDF_WATERMARK watermark)
 Release a watermark object. More...
 
FS_RESULT FSPDF_Page_RemoveWatermarks (FSCRT_PAGE page)
 Remove all watermarks from a specific page. More...
 
FS_RESULT FSPDF_Watermark_Remove (FSCRT_PAGE page, FS_INT32 index)
 Remove a watermark by index from a PDF page and it does not include the SDK trial watermark. More...
 

Macro Definitions for Watermark Positions.

#define FSPDF_WATERMARKPOS_TOPLEFT   0
 Watermark position: top left.
 
#define FSPDF_WATERMARKPOS_TOPCENTER   1
 Watermark position: top center.
 
#define FSPDF_WATERMARKPOS_TOPRIGHT   2
 Watermark position: top right.
 
#define FSPDF_WATERMARKPOS_CENTERLEFT   3
 Watermark position: center left.
 
#define FSPDF_WATERMARKPOS_CENTER   4
 Watermark position: center.
 
#define FSPDF_WATERMARKPOS_CENTERRIGHT   5
 Watermark position: center right.
 
#define FSPDF_WATERMARKPOS_BOTTOMLEFT   6
 Watermark position: bottom left.
 
#define FSPDF_WATERMARKPOS_BOTTOMCENTER   7
 Watermark position: bottom center.
 
#define FSPDF_WATERMARKPOS_BOTTOMRIGHT   8
 Watermark position: bottom right.
 

Macro Definitions for Watermark Setting Flags.

#define FSPDF_WATERMARKFLAG_ASPAGECONTENTS   0
 If set and insert a watermark as page content (default).
 
#define FSPDF_WATERMARKFLAG_ASANNOT   1
 If set and insert a watermark as an annotation.
 
#define FSPDF_WATERMARKFLAG_ONTOP   2
 If set, show watermark above other page content.
 
#define FSPDF_WATERMARKFLAG_NOPRINT   4
 If set but do not print a watermark.
 
#define FSPDF_WATERMARKFLAG_INVISIBLE   8
 If set but do not display a watermark.
 

Macro Definitions for Watermark Text Font Style.

#define FSPDF_WATERMARK_FONTSTYLE_NORMAL   0
 Watermark font style: normal.
 
#define FSPDF_WATERMARK_FONTSTYLE_UNDERLINE   1
 Watermark font style: with underline.
 

Macro Definitions for a watermark alignment Mode.

#define FSPDF_WATERMARK_TEXTALIGNMENT_LEFT   0
 Text watermark alignment: left.
 
#define FSPDF_WATERMARK_TEXTALIGNMENT_CENTER   1
 Text watermark alignment: center.
 
#define FSPDF_WATERMARK_TEXTALIGNMENT_RIGHT   2
 Text watermark alignment: right.
 

Detailed Description

Definitions for PDF watermarks.
Definitions and functions in this module are included in fpdf_watermark_r.h and fpdf_watermark_w.h.
Module: PDFWatermark
License Identifier: PDFWatermark/All
Available License Right: Reading/Writing
For License Right Reading, see fpdf_watermark_r.h.
For License Right Writing, see fpdf_watermark_w.h.

This module contains the following features:

Function Documentation

FS_RESULT FSPDF_Page_RemoveWatermarks ( FSCRT_PAGE  page)

Remove all watermarks from a specific page.

The page content should have been already parsed. And there is no need to call function FSPDF_Page_LoadAnnots at first for watermarks which are annotations.

Parameters
[in]pageHandle to a FSCRT_PAGE object which is a PDF page object.
Returns
FSCRT_ERRCODE_SUCCESS for success.
FSCRT_ERRCODE_PARAM if the parameter page is NULL.
FSCRT_ERRCODE_INVALIDTYPE if the parameter page is an invalid type.
FSCRT_ERRCODE_NOTPARSED if the parameterpage is not parsed.
FSCRT_ERRCODE_UNRECOVERABLE if an unrecoverable error occurs internally.
FSCRT_ERRCODE_OUTOFMEMORY if there is not enough memory or invalid memory access.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
Attention
Thread Safety: this function is thread safe.
OOM Information:
OOM handling is only for mobile platforms, not for server or desktop.
  • This function is long-term unrecoverable.
  • page: this handle is long-term partially recoverable.
Please refer to the document "Robust PDF Applications with Limited Memory" for more details.
FS_RESULT FSPDF_Watermark_CreateFromBitmap ( FSCRT_DOCUMENT  document,
FSCRT_BITMAP  bitmap,
const FSPDF_WATERMARK_SETTINGS settings,
FSPDF_WATERMARK *  watermark 
)

Create a bitmap watermark.

Parameters
[in]documentHandle to FSCRT_DOCUMENT object, and the PDF document object which the created watermark will be used for.
[in]bitmapHandle to FSCRT_BITMAP object which is to be shown as watermark.
[in]settingsPointer to a FSPDF_WATERMARK_SETTINGS structure that contains layout settings for this watermark.
[out]watermarkPointer to a FSPDF_WATERMARK handle that receives the watermark handle.
If no need to use this handle any more, please call function FSPDF_Watermark_Release to release it.
Returns
FSCRT_ERRCODE_SUCCESS for success.
FSCRT_ERRCODE_PARAM if the parameter document, bitmap, settings, or watermark is NULL.
FSCRT_ERRCODE_INVALIDLICENSE if the current license is not authorized or creating watermark is not allowed.
FSCRT_ERRCODE_INVALIDMODULE if the current PDF module is not initialized.
FSCRT_ERRCODE_INVALIDTYPE if the parameter document is an invalid type.
FSCRT_ERRCODE_UNRECOVERABLE if an unrecoverable error occurs.
FSCRT_ERRCODE_OUTOFMEMORY if there is not enough memory or invalid memory access.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
Attention
Thread Safety: this function is thread safe.
OOM Information:
OOM handling is only for mobile platforms, not for server or desktop.
  • This function is long-term recoverable.
  • document: this handle is long-term partially recoverable.
  • bitmap: this handle is long-term recoverable.
  • watermark: this handle is long-term recoverable.
Please refer to the document "Robust PDF Applications with Limited Memory" for more details.
FS_RESULT FSPDF_Watermark_CreateFromImage ( FSCRT_DOCUMENT  document,
FSCRT_IMAGE  image,
const FSPDF_WATERMARK_SETTINGS settings,
FSPDF_WATERMARK *  watermark 
)

Create an image watermark.

The parameter watermark can only be set in one frame, so callers shall call FSCRT_Image_LoadFrame first to obtain a frame.

Parameters
[in]documentHandle to the FSCRT_DOCUMENT object, and a PDF document object which the created watermark will be used for.
[in]imageHandle to the FSCRT_IMAGE object in which a frame will be shown as a watermark .
[in]settingsPointer to a FSPDF_WATERMARK_SETTINGS structure which contains layout settings for this watermark.
[out]watermarkPointer to a FSPDF_WATERMARK handle that receives a watermark handle.
If no need to use this handle any more, please call function FSPDF_Watermark_Release to release it.
Returns
FSCRT_ERRCODE_SUCCESS for success.
FSCRT_ERRCODE_PARAM if the parameter document, image, settings, or watermark is NULL.
FSCRT_ERRCODE_INVALIDLICENSE if the current license is not authorized or creating watermark is not allowed.
FSCRT_ERRCODE_INVALIDMODULE if the current PDF module is not initialized.
FSCRT_ERRCODE_INVALIDTYPE if the parameter document is an invalid type.
FSCRT_ERRCODE_NOTFOUND if callers do not load any one frame of the image.
FSCRT_ERRCODE_UNRECOVERABLE if function finds an unrecoverable error internally.
FSCRT_ERRCODE_OUTOFMEMORY if there is not enough memory or invalid memory access.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
Note
A image file should be released after saving a document.
Attention
Thread Safety: this function is thread safe.
OOM Information:
OOM handling is only for mobile platforms, not for server or desktop.
  • This function is long-term recoverable.
  • document: this handle is long-term partially recoverable.
  • image: this handle is long-term recoverable.
  • watermark: this handle is long-term recoverable.
Please refer to the document "Robust PDF Applications with Limited Memory" for more details.
FS_RESULT FSPDF_Watermark_CreateFromPage ( FSCRT_DOCUMENT  document,
FSCRT_PAGE  page,
const FSPDF_WATERMARK_SETTINGS settings,
FSPDF_WATERMARK *  watermark 
)

Create a page watermark.

Parameters
[in]documentHandle to a FSCRT_DOCUMENT object, and a PDF document object which the created watermark will be used for.
[in]pageHandle to a FSCRT_PAGE object which is a PDF page shown as watermark.
[in]settingsPointer to a FSPDF_WATERMARK_SETTINGS structure which contains layout settings for this watermark.
[out]watermarkPointer to a FSPDF_WATERMARK handle that receives a watermark handle.
If no need to use this handle any more, please call function FSPDF_Watermark_Release to release it.
Returns
FSCRT_ERRCODE_SUCCESS for success.
FSCRT_ERRCODE_PARAM if the parameter document, page, settings, or watermark is NULL.
FSCRT_ERRCODE_INVALIDLICENSE if the current license is not authorized or creating watermark is not allowed.
FSCRT_ERRCODE_INVALIDMODULE if the current PDF module is not initialized.
FSCRT_ERRCODE_INVALIDTYPE if the document is an invalid type or the page is an invalid type.
FSCRT_ERRCODE_NOTPARSED if the page is not parsed when being converted to a watermark.
FSCRT_ERRCODE_UNRECOVERABLE if an unrecoverable error occurs internally.
FSCRT_ERRCODE_OUTOFMEMORY if there is not enough memory or invalid memory access.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
Attention
Thread Safety: this function is thread safe.
OOM Information:
OOM handling is only for mobile platforms, not for server or desktop.
  • This function is long-term unrecoverable.
  • document: this handle is long-term partially recoverable.
  • page: this handle is long-term partially recoverable.
  • watermark: this handle is long-term partially recoverable.
Please refer to the document "Robust PDF Applications with Limited Memory" for more details.
FS_RESULT FSPDF_Watermark_CreateFromText ( FSCRT_DOCUMENT  document,
const FSCRT_BSTR text,
const FSPDF_WATERMARK_TEXTPROPERTIES properties,
const FSPDF_WATERMARK_SETTINGS settings,
FSPDF_WATERMARK *  watermark 
)

Create a text watermark.

Parameters
[in]documentHandle to FSCRT_DOCUMENT object, and the PDF document object which the created watermark will be used for.
[in]textPointer to a text string, it should be a valid pointer to FSCRT_BSTR. It specifies the content of watermark.
[in]propertiesPointer to a FSPDF_WATERMARK_TEXTPROPERTIES structure containing text specific properties for this watermark.
[in]settingsPointer to a FSPDF_WATERMARK_SETTINGS structure containing layout settings for this watermark.
[out]watermarkPointer to a FSPDF_WATERMARK handle that receives the watermark handle.
If no need to use this handle any more, please call function FSPDF_Watermark_Release to release it.
Returns
FSCRT_ERRCODE_SUCCESS for success.
FSCRT_ERRCODE_PARAM if parameter document, text, properties, settings, or watermark is NULL, or parameter text is empty.
FSCRT_ERRCODE_INVALIDLICENSE if the current license is not authorized or creating watermark is not allowed.
FSCRT_ERRCODE_INVALIDMODULE if the current PDF module is not initialized.
FSCRT_ERRCODE_INVALIDTYPE if the parameter document is an invalid type.
FSCRT_ERRCODE_UNRECOVERABLE if an unrecoverable error occurs.
FSCRT_ERRCODE_OUTOFMEMORY if there is not enough memory or invalid memory access.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
Attention
Thread Safety: this function is thread safe.
OOM Information:
OOM handling is only for mobile platforms, not for server or desktop.
  • This function is long-term recoverable.
  • document: this handle is long-term partially recoverable.
  • watermark: this handle is long-term recoverable.
Please refer to the document "Robust PDF Applications with Limited Memory" for more details.
FS_RESULT FSPDF_Watermark_GetCount ( FSCRT_PAGE  page,
FS_INT32 count 
)

Get count of watermarks in a specific page and it does not include the SDK trial watermark.

The page content should have been already parsed. And there is no need to call function FSPDF_Page_LoadAnnots at first for watermarks which are annotations.

Parameters
[in]pageHandle to a FSCRT_PAGE which is a PDF page object.
[out]countPointer to a FS_INT32 object that receives count of watermarks. If there is any error, it will be set 0.
Returns
FSCRT_ERRCODE_SUCCESS for success.
FSCRT_ERRCODE_PARAM if parameter page, or count is NULL.
FSCRT_ERRCODE_NOTPARSED if the parameterpage is not parsed.
FSCRT_ERRCODE_INVALIDTYPE if parameter page is not a type of PDF page.
FSCRT_ERRCODE_OUTOFMEMORY if there is not enough memory or if the memory access is wrong.
FSCRT_ERRCODE_ERROR if count cannot be obtained because of any other reason.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
Attention
Thread Safety: this function is thread safe.
OOM Information:
OOM handling is only for mobile platforms, not for server or desktop.
  • This function is short-term.
  • page: this handle is long-term partially recoverable.
Please refer to the document "Robust PDF Applications with Limited Memory" for more details.
FS_RESULT FSPDF_Watermark_GetSize ( FSPDF_WATERMARK  watermark,
FS_FLOAT width,
FS_FLOAT height 
)

Retrieve the size (width and height) of a specific watermark.

Parameters
[in]watermarkHandle to FSPDF_WATERMARK object which is a water mark object.
[out]widthPointer to a FS_FLOAT object that retrieves the width of watermark.
[out]heightPointer to a FS_FLOAT object that retrieves the height of watermark.
Returns
FSCRT_ERRCODE_SUCCESS for success.
FSCRT_ERRCODE_PARAM if the parameter watermark, width, or height is NULL.
FSCRT_ERRCODE_UNRECOVERABLE if an unrecoverable error occurs internally.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
Attention
Thread Safety: this function is thread safe. OOM Information:
OOM handling is only for mobile platforms, not for server or desktop.
Please refer to the document "Robust PDF Applications with Limited Memory" for more details.
FS_RESULT FSPDF_Watermark_InsertToPage ( FSPDF_WATERMARK  watermark,
FSCRT_PAGE  page 
)

Insert a watermark into a specific page.

The page content should have been already parsed. And there is no need to call function FSPDF_Page_LoadAnnots at first for watermarks which are annotations.

Parameters
[in]watermarkHandle to a FSPDF_WATERMARK object which is a water mark object.
[in]pageHandle to a FSCRT_PAGE object which is a PDF page object.
Returns
FSCRT_ERRCODE_SUCCESS for success.
FSCRT_ERRCODE_PARAM if the parameter parameter watermark, or page is NULL.
FSCRT_ERRCODE_INVALIDTYPE if the parameter page is an invalid type.
FSCRT_ERRCODE_NOTPARSED if the parameterpage is not parsed.
FSCRT_ERRCODE_UNRECOVERABLE if an unrecoverable error occurs internally.
FSCRT_ERRCODE_OUTOFMEMORY if there is not enough memory or invalid memory access.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
Attention
Thread Safety: this function is thread safe.
OOM Information:
OOM handling is only for mobile platforms, not for server or desktop.
Please refer to the document "Robust PDF Applications with Limited Memory" for more details.
FS_RESULT FSPDF_Watermark_Release ( FSPDF_WATERMARK  watermark)

Release a watermark object.

Parameters
[in]watermarkHandle to FSPDF_WATERMARK object which is a water mark object.
Returns
FSCRT_ERRCODE_SUCCESS for success.
FSCRT_ERRCODE_PARAM if the parameter watermark is NULL.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
Attention
Thread Safety: this function is not thread safe. Applications need to make sure thread safety by themselves when accessing the same objects during multi-thread environments.
OOM Information:
OOM handling is only for mobile platforms, not for server or desktop.
Please refer to the document "Robust PDF Applications with Limited Memory" for more details.
FS_RESULT FSPDF_Watermark_Remove ( FSCRT_PAGE  page,
FS_INT32  index 
)

Remove a watermark by index from a PDF page and it does not include the SDK trial watermark.

The page content should have been already parsed. And there is no need to call function FSPDF_Page_LoadAnnots at first for watermarks which are annotations.

Parameters
[in]pageHandle to a FSCRT_PAGE object which is a PDF page object.
[in]indexA zero-based index of watermark to be got. Range: 0 to (WatermarkCount-1). WatermarkCount is returned by function FSPDF_Watermark_GetCount with the same page
Returns
FSCRT_ERRCODE_SUCCESS for success.
FSCRT_ERRCODE_PARAM if parameter page is NULL.
FSCRT_ERRCODE_NOTFOUND if index is out of range or there are no watermarks.
FSCRT_ERRCODE_NOTPARSED if the parameterpage is not parsed.
FSCRT_ERRCODE_UNRECOVERABLE if an unrecoverable error occurs internally.
FSCRT_ERRCODE_OUTOFMEMORY if there is not enough memory or invalid memory access.
FSCRT_ERRCODE_ERROR if the watermark cannot be removed because of any other reason.
For more error codes, please refer to macro definitions FSCRT_ERRCODE_XXX.
Attention
Thread Safety: this function is thread safe.
OOM Information:
OOM handling is only for mobile platforms, not for server or desktop.
  • This function is long-term unrecoverable.
  • page: this handle is long-term partially recoverable.
Please refer to the document "Robust PDF Applications with Limited Memory" for more details.

Foxit Corporation