/*
* Copyright (C) 2017 zyx [@:] zyx gmx [dot] us
*
* The litePDF library is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, the version 3
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program. If not, see
Main features of litePDF:
| a b 0 |
| c d 0 |
| e f 1 |
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param resourceID Resource ID to draw.
@param pageIndex Page index to which draw; counts from 0.
@param a Transformation matrix [ a b c d e f ] parameter 'a', in 1/1000th of PDF units.
@param b Transformation matrix [ a b c d e f ] parameter 'b', in 1/1000th of PDF units.
@param c Transformation matrix [ a b c d e f ] parameter 'c', in 1/1000th of PDF units.
@param d Transformation matrix [ a b c d e f ] parameter 'd', in 1/1000th of PDF units.
@param e Transformation matrix [ a b c d e f ] parameter 'e', in 1/1000th of PDF units.
@param f Transformation matrix [ a b c d e f ] parameter 'f', in 1/1000th of PDF units.
@return Whether succeeded.
@see litePDF_GetPageCount, litePDF_AddPageFromAsResource, litePDF_FinishResource,
litePDF_GetResourceSize, litePDF_DrawResource
*/
#define LITEPDF_DOCUMENT_INFO_AUTHOR "Author" /**< an Author of the document */
#define LITEPDF_DOCUMENT_INFO_CREATOR "Creator" /**< a Creator of the document */
#define LITEPDF_DOCUMENT_INFO_KEYWORDS "Keywords" /**< the Keywords of the document */
#define LITEPDF_DOCUMENT_INFO_SUBJECT "Subject" /**< a Subject of the document */
#define LITEPDF_DOCUMENT_INFO_TITLE "Title" /**< a Title of the document */
#define LITEPDF_DOCUMENT_INFO_PRODUCER "Producer" /**< a Producer of the document; this key is read-only */
#define LITEPDF_DOCUMENT_INFO_TRAPPED "Trapped" /**< a trapping state of the document */
#define LITEPDF_DOCUMENT_INFO_CREATION_DATE "CreationDate" /**< a date of the creation of the document */
#define LITEPDF_DOCUMENT_INFO_MODIFICATION_DATE "ModDate" /**< a date of the last modification of the document */
BOOL __stdcall LITEPDF_PUBLIC litePDF_SetDocumentInfo(void *pctx,
const char *name,
const wchar_t *value);
/**<
Sets information about the document. The name can be one
of the LITEPDF_DOCUMENT_INFO predefined constants.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param name Document info property name to set.
@param value Null-terminated Unicode value to set.
@return Whether succeeded.
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetDocumentInfoExists(void *pctx,
const char *name,
BOOL *pExists);
/**<
Checks whether information about the document of the given name exists.
The name can be one of the LITEPDF_DOCUMENT_INFO predefined constants.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param name Document info property name to test.
@param pExists [out] Where to store whether the document information is set.
@return Whether succeeded.
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetDocumentInfo(void *pctx,
const char *name,
wchar_t *value,
unsigned int *valueLength);
/**<
Gets information about the document. The name can be one
of the LITEPDF_DOCUMENT_INFO predefined constants.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param name Document info property name to get.
@param value [out] Null-terminated Unicode value. It can be NULL, in which case
the @a valueLength is populated with large-enough value to hold the whole string.
@param valueLength [in/out] Tells how many characters can be stored in @a value. If @a value
is NULL, then it is set to large-enough value (not including the Null-termination character).
Passing non-NULL @a value with no enough large buffer results in a failure with no change
on @a valueLength. The @a valueLength has stored count of characters written, not including
the Null-termination character on success.
@return Whether succeeded.
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetDocumentIsSigned(void *pctx,
BOOL *pIsSigned);
/**<
Checks whether currently opened document is already signed. Signing already
signed document can cause breakage of previous signatures, thus it's good
to test whether the loaded document is signed, before signing it.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param pIsSigned [out] Where to store the result.
@return Whether succeeded.
@see litePDF_GetSignatureCount, litePDF_SaveToFileWithSign, litePDF_SaveToDataWithSign
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetSignatureCount(void *pctx,
unsigned int *pCount);
/**<
Provides how many signature fields the currently opened document contains.
It returns the count of the all fields, not only those already signed.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param pCount [out] Where to store the result.
@return Whether succeeded.
@note The litePDF caches the list of the existing signature fields for performance
reasons and it rebuilds it whenever this function is called or when the
@ref litePDF_CreateSignature is called, thus if there are made any changes
directly with the PoDoFo API after the cache had been created, then make sure
you call this function again to avoid a use-after-free or an outdated information
being used. The litePDF will try to keep the cache up to date as needed, but
it cannot cover every case, especially not the one when the PoDoFo API is used.
@see litePDF_GetDocumentIsSigned, litePDF_GetSignatureHasData, litePDF_GetSignatureData
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetSignatureName(void *pctx,
unsigned int index,
char *name,
unsigned int *nameLength);
/**<
Gets the signature field name at the given @a index.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature field name to get; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param name [out] Null-terminated ASCII name. It can be NULL, in which case
the @a nameLength is populated with large-enough value to hold the whole string.
@param nameLength [in/out] Tells how many characters can be stored in @a name. If @a name
is NULL, then it is set to large-enough value (not including the Null-termination character).
Passing non-NULL @a name with no enough large buffer results in a failure with no change
on @a nameLength. The @a nameLength has stored count of characters written, not including
the Null-termination character, on success.
@return Whether succeeded.
*/
#define LITEPDF_ANNOTATION_FLAG_NONE 0x0000 /**< Default annotation flags */
#define LITEPDF_ANNOTATION_FLAG_INVISIBLE 0x0001 /**< Do not show nonstandard annotation if there is no annotation handler available */
#define LITEPDF_ANNOTATION_FLAG_HIDDEN 0x0002 /**< Do not allow show, print or interact with the annotation */
#define LITEPDF_ANNOTATION_FLAG_PRINT 0x0004 /**< Print the annotation */
#define LITEPDF_ANNOTATION_FLAG_NOZOOM 0x0008 /**< Do not scale the annotation's appearance to match the magnification of the page */
#define LITEPDF_ANNOTATION_FLAG_NOROTATE 0x0010 /**< Do not rotate the annotation's appearance to match the rotation of the page */
#define LITEPDF_ANNOTATION_FLAG_NOVIEW 0x0020 /**< Do not display the annotation on the screen or allow it to interact with the user */
#define LITEPDF_ANNOTATION_FLAG_READONLY 0x0040 /**< Do not allow the annotation to interact with the user */
#define LITEPDF_ANNOTATION_FLAG_LOCKED 0x0080 /**< Do not allow the annotation to be deleted or its properties (including position and size) to be modified by the user */
#define LITEPDF_ANNOTATION_FLAG_TOGGLENOVIEW 0x0100 /**< Invert the interpretation of the NoView flag for certain events */
#define LITEPDF_ANNOTATION_FLAG_LOCKEDCONTENTS 0x0200 /**< Do not allow the contents of the annotation to be modified by the user */
BOOL __stdcall LITEPDF_PUBLIC litePDF_CreateSignature(void *pctx,
const char *name,
unsigned int annotationPageIndex,
int annotationX_u,
int annotationY_u,
int annotationWidth_u,
int annotationHeight_u,
unsigned int annotationFlags,
unsigned int *pAddedIndex);
/**<
Creates a new signature field named @a name. The field is created completely empty.
Use @ref litePDF_SetSignatureDate, @ref litePDF_SetSignatureReason,
@ref litePDF_SetSignatureLocation, @ref litePDF_SetSignatureCreator,
@ref litePDF_SetSignatureAppearance and such to populate it with required values.
Finally, to sign the signature field use @ref litePDF_SaveToFileWithSign family
functions.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param name Signature field name to use. This should be unique.
@param annotationPageIndex Page index where to place the signature annotation.
@param annotationX_u X-origin of the annotation on the page, in the current unit.
@param annotationY_u Y-origin of the annotation on the page, in the current unit.
@param annotationWidth_u Width of the annotation on the page, in the current unit.
@param annotationHeight_u Height of the annotation on the page, in the current unit.
@param annotationFlags Bit-or of LITEPDF_ANNOTATION_FLAG_ flags.
@param pAddedIndex [out] Optional parameter, if not NULL, then it's populated with
the index of the added signature field.
@return Whether succeeded. The call can also fail when a signature field of the same
name already exists.
@see litePDF_GetSignatureCount, litePDF_GetSignatureName
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetSignatureHasData(void *pctx,
unsigned int index,
BOOL *pHasData);
/**<
Checks whether the given signature field contains any data, which
means whether the signature field is signed.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature data to get; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param pHasData [out] Set to TRUE, when the given signature contains any data.
@return Whether succeeded.
@see litePDF_GetSignatureData
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetSignatureData(void *pctx,
unsigned int index,
BYTE *data,
unsigned int *dataLength);
/**<
Gathers raw signature data for the given signature in the currently opened document.
Use @ref litePDF_GetSignatureHasData to check whether the given signature field
is signed or not.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature data to get; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param data [out] Actual data to store the signature content to. It can be NULL, in which case
the @a dataLength is populated with large-enough value to hold the whole data.
@param dataLength [in/out] Tells how many bytes can be stored in @a data. If @a data
is NULL, then it is set to large-enough value. Passing non-NULL @a data with no enough
large buffer results in a failure with no change on @a dataLength.
@return Whether succeeded.
@see litePDF_GetDocumentIsSigned, litePDF_GetSignatureCount, litePDF_GetSignatureRanges
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetSignatureRanges(void *pctx,
unsigned int index,
unsigned __int64 *pRangesArray,
unsigned int *pRangesArrayLength);
/**<
Gathers signature ranges, that is the actual offsets into the opened file
which had been used to create the signature data (@ref litePDF_GetSignatureData).
The array is a pair of numbers, where the first number is an offset into the file
from its beginning and the second number is the number of bytes being used for
the signature from this offset.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature ranges to get; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param pRangesArray [out] Actual array to store the signature ranges to. It can be NULL,
in which case the @a pRangesArrayLength is populated with large-enough value to hold
the whole array.
@param pRangesArrayLength [in/out] Tells how many items can be stored in @a pRangesArray.
If @a pRangesArray is NULL, then it is set to large-enough value. Passing non-NULL
@a pRangesArray with no enough large array results in a failure with no change
on @a pRangesArrayLength.
@return Whether succeeded.
@note This function works only for the signatures which use this kind of signature method.
@see litePDF_GetDocumentIsSigned, litePDF_GetSignatureCount, litePDF_GetSignatureData
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SetSignatureDate(void *pctx,
unsigned int index,
__int64 dateOfSign);
/**<
Sets signature field date of sign.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param dateOfSign Date of sign, like Unix time_t, when the signature was created; less than
or equal to 0 means today. The value can be clamp on 32-bit systems.
@return Whether succeeded.
@see litePDF_GetSignatureDate, litePDF_GetSignatureCount
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetSignatureDate(void *pctx,
unsigned int index,
__int64 *pDateOfSign);
/**<
Gets signature field date of sign.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param pDateOfSign [out] A variable where to store the date of sign. It's like Unix time_t,
as set by the signature field creator. The value can be clamp on 32-bit systems.
@return Whether succeeded.
@see litePDF_SetSignatureDate, litePDF_GetSignatureCount
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SetSignatureReason(void *pctx,
unsigned int index,
const wchar_t *reason);
/**<
Sets signature reason.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param reason The value to set.
@return Whether succeeded.
@see litePDF_GetSignatureReason, litePDF_GetSignatureCount
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetSignatureReason(void *pctx,
unsigned int index,
wchar_t *value,
unsigned int *valueLength);
/**<
Gets signature reason.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param value [out] Null-terminated Unicode value. It can be NULL, in which case
the @a valueLength is populated with large-enough value to hold the whole string.
@param valueLength [in/out] Tells how many characters can be stored in @a value. If @a value
is NULL, then it is set to large-enough value (not including the Null-termination character).
Passing non-NULL @a value with no enough large buffer results in a failure with no change
on @a valueLength. The @a valueLength has stored count of characters written, not including
the Null-termination character on success.
@return Whether succeeded.
@see litePDF_SetSignatureReason, litePDF_GetSignatureCount
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SetSignatureLocation(void *pctx,
unsigned int index,
const wchar_t *location);
/**<
Sets signature location, aka where the signature had been made. This can be left unset.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param location The value to set.
@return Whether succeeded.
@see litePDF_GetSignatureLocation, litePDF_GetSignatureCount
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetSignatureLocation(void *pctx,
unsigned int index,
wchar_t *value,
unsigned int *valueLength);
/**<
Gets signature location.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param value [out] Null-terminated Unicode value. It can be NULL, in which case
the @a valueLength is populated with large-enough value to hold the whole string.
@param valueLength [in/out] Tells how many characters can be stored in @a value. If @a value
is NULL, then it is set to large-enough value (not including the Null-termination character).
Passing non-NULL @a value with no enough large buffer results in a failure with no change
on @a valueLength. The @a valueLength has stored count of characters written, not including
the Null-termination character on success.
@return Whether succeeded.
@see litePDF_SetSignatureLocation, litePDF_GetSignatureCount
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SetSignatureCreator(void *pctx,
unsigned int index,
const char *creator);
/**<
Sets signature creator. This can be left unset.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param creator The value to set.
@return Whether succeeded.
@see litePDF_GetSignatureCreator, litePDF_GetSignatureCount
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetSignatureCreator(void *pctx,
unsigned int index,
char *value,
unsigned int *valueLength);
/**<
Gets signature creator.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param value [out] Null-terminated ASCII value. It can be NULL, in which case
the @a valueLength is populated with large-enough value to hold the whole string.
@param valueLength [in/out] Tells how many characters can be stored in @a value. If @a value
is NULL, then it is set to large-enough value (not including the Null-termination character).
Passing non-NULL @a value with no enough large buffer results in a failure with no change
on @a valueLength. The @a valueLength has stored count of characters written, not including
the Null-termination character on success.
@return Whether succeeded.
@see litePDF_SetSignatureCreator, litePDF_GetSignatureCount
*/
#define LITEPDF_APPEARANCE_NORMAL (0) /**< Normal appearance */
#define LITEPDF_APPEARANCE_ROLLOVER (1) /**< Rollover appearance; the default is the normal appearance */
#define LITEPDF_APPEARANCE_DOWN (2) /**< Down appearance; the default is the normal appearance */
BOOL __stdcall LITEPDF_PUBLIC litePDF_SetSignatureAppearance(void *pctx,
unsigned int index,
unsigned int appearanceType,
unsigned int resourceID,
int offsetX_u,
int offsetY_u);
/**<
Sets the signature appearance.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param appearanceType One of the @ref LITEPDF_APPEARANCE_NORMAL, @ref LITEPDF_APPEARANCE_ROLLOVER
and @ref LITEPDF_APPEARANCE_DOWN constants. At least the @ref LITEPDF_APPEARANCE_NORMAL type
should be set, if the appearance of the signature is requested.
@param resourceID An existing resource ID of the annotation content, as shown to the user.
@param offsetX_u X-offset of the resource inside the annotation of the signature, in the current unit.
@param offsetY_u Y-offset of the resource inside the annotation of the signature, in the current unit.
@return Whether succeeded.
@note The resource position offset is from [left, top] corner of the annotation rectangle.
@see litePDF_GetUnit, litePDF_AddResource, litePDF_GetSignatureCount, litePDF_CreateSignature
*/
#define LITEPDF_CERTIFICATION_PERMISSION_NO_PERMS (1) /**< No changes to the document are permitted; any change to the document invalidates the signature. */
#define LITEPDF_CERTIFICATION_PERMISSION_FORM_FILL (2) /**< Permitted changes are filling in forms, instantiating page templates, and signing; other changes invalidate the signature. */
#define LITEPDF_CERTIFICATION_PERMISSION_ANNOTATIONS (3) /**< Permitted changes are the same as for @ref LITEPDF_CERTIFICATION_PERMISSION_FORM_FILL, as well as annotation creation, deletion, and modification; other changes invalidate the signature. */
BOOL __stdcall LITEPDF_PUBLIC litePDF_SetSignatureCertification(void *pctx,
unsigned int index,
unsigned int permission);
/**<
Sets the signature certification. This is used to detect modifications relative to a signature
field that is signed by the author of a document (the person applying the first signature). A document
can contain only one signature field that contains the access permissions; it should be the first
signed field in the document. It enables the author to specify what changes are permitted to be
made the document and what changes invalidate the author’s signature.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param permission One of the @ref LITEPDF_CERTIFICATION_PERMISSION_NO_PERMS, @ref LITEPDF_CERTIFICATION_PERMISSION_FORM_FILL
and @ref LITEPDF_CERTIFICATION_PERMISSION_ANNOTATIONS constants.
@see litePDF_CreateSignature
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SetSignatureSize(void *pctx,
unsigned int requestBytes);
/**<
Sets how many bytes the signature may require. The default value is 4096 bytes
and it is automatically adjusted when the @ref litePDF_SaveToFileWithSign or
@ref litePDF_SaveToDataWithSign are used. The manual signing functions
require this value to be set before signing, if the final hash with the certificate
exceeds the default size.
This value is remembered in general, not for any signature in particular.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param requestBytes How many bytes the signature will require.
@return Whether succeeded.
@see litePDF_SetSignatureHash, litePDF_SaveToFileWithSignManual, litePDF_SaveToFileWithSignManualW, litePDF_SaveToDataWithSignManual
*/
#define LITEPDF_SIGNATURE_HASH_SHA1 1 /**< Use SHA1 hash algorithm */
#define LITEPDF_SIGNATURE_HASH_SHA256 2 /**< Use SHA256 hash algorithm */
#define LITEPDF_SIGNATURE_HASH_SHA384 3 /**< Use SHA384 hash algorithm */
#define LITEPDF_SIGNATURE_HASH_SHA512 4 /**< Use SHA512 hash algorithm */
BOOL __stdcall LITEPDF_PUBLIC litePDF_SetSignatureHash(void *pctx,
unsigned int signatureHash);
/**<
Sets the signature hash algorithm to be used. The default value is @ref LITEPDF_SIGNATURE_HASH_SHA512.
It is used only when the @ref litePDF_SaveToFileWithSign or
@ref litePDF_SaveToDataWithSign are used. The supported
values are @ref LITEPDF_SIGNATURE_HASH_SHA1, @ref LITEPDF_SIGNATURE_HASH_SHA256,
@ref LITEPDF_SIGNATURE_HASH_SHA384 and @ref LITEPDF_SIGNATURE_HASH_SHA512.
This value is remembered in general, not for any signature in particular.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param signatureHash The hash algorithm to use.
@return Whether succeeded.
@see litePDF_SetSignatureSize, litePDF_SaveToFileWithSignManual, litePDF_SaveToFileWithSignManualW, litePDF_SaveToDataWithSignManual
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_AddSignerPFX(void *pctx,
const BYTE *pfxData,
unsigned int pfxDataLength,
const char *pfxPassword);
/**<
Adds a signer to be used when digitally signing the document with
@ref litePDF_SaveToFileWithSign or @ref litePDF_SaveToDataWithSign.
The passed-in certificate is in the PFX format and should include
the private key.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param pfxData A certificate with private key in the PFX format.
@param pfxDataLength A length of the @a pfxData.
@param pfxPassword A password to use to open the PFX certificate; can be NULL.
@return Whether succeeded.
@see litePDF_AddSignerPEM
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_AddSignerPEM(void *pctx,
const BYTE *pemData,
unsigned int pemDataLength,
const BYTE *pkeyData,
unsigned int pkeyDataLength,
const char *pkeyPassword);
/**<
Adds a signer to be used when digitally signing the document with
@ref litePDF_SaveToFileWithSign or @ref litePDF_SaveToDataWithSign.
The passed-in certificate and private key are in the PEM format.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param pemData A certificate in the PEM format.
@param pemDataLength A length of the @a pemData.
@param pkeyData A private key for the certificate, in the PEM format.
@param pkeyDataLength A length of the @a pkeyData.
@param pkeyPassword A password to use to open the private key; can be NULL.
@return Whether succeeded.
@see litePDF_AddSignerPFX
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SaveToFileWithSign(void *pctx,
const char *fileName,
unsigned int signatureIndex);
/**<
Digitally signs a PDF document opened at the litePDF context. The caller is
responsible to set at least one signer with either @ref litePDF_AddSignerPFX
or @ref litePDF_AddSignerPEM first. An alternative @ref litePDF_SaveToFileWithSignManual
is provided when it's required to compute the signature hash manually by the caller.
In case the document had been loaded with @ref litePDF_LoadFromFile,
@ref litePDF_LoadFromFileW or @ref litePDF_LoadFromData with its @a forUpdate
parameter being TRUE, the resulting document will contain the changes as
an incremental update (appended at the end of the original document), otherwise
the whole document is completely rewritten.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param fileName A file name where to save signed PDF document.
@param signatureIndex Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@return Whether succeeded.
@note The only valid operation after this is either close the document
with @ref litePDF_Close, or free the context with @ref litePDF_FreeContext.
@note Signing already signed document can cause breakage of previous signatures, thus
check whether the loaded document is already signed with @ref litePDF_GetDocumentIsSigned.
Load the document with its @a forUpdate parameter set to TRUE, to sign an existing document.
@see litePDF_SaveToFileWithSignW, litePDF_SaveToDataWithSign
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SaveToFileWithSignW(void *pctx,
const wchar_t *fileName,
unsigned int signatureIndex);
/**<
This is the same as @ref litePDF_SaveToFileWithSign, the only difference is that
the @a fileName is a wide string.
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SaveToDataWithSign(void *pctx,
unsigned int signatureIndex,
BYTE *data,
unsigned int *dataLength);
/**<
Digitally signs a PDF document opened at the litePDF context. The caller is
responsible to set at least one signer with either @ref litePDF_AddSignerPFX
or @ref litePDF_AddSignerPEM first. An alternative @ref litePDF_SaveToDataWithSignManual
is provided when it's required to compute the signature hash manually by the caller.
In case the document had been loaded with @ref litePDF_LoadFromFile,
@ref litePDF_LoadFromFileW or @ref litePDF_LoadFromData with its @a forUpdate
parameter being TRUE, the resulting document will contain the changes as
an incremental update (appended at the end of the original document), otherwise
the whole document is completely rewritten.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param signatureIndex Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param data [out] Actual data to store the PDF content to. It can be NULL, in which case
the @a dataLength is populated with large-enough value to hold the whole data.
@param dataLength [in/out] Tells how many bytes can be stored in @a data. If @a data
is NULL, then it is set to large-enough value. Passing non-NULL @a data with no enough
large buffer results in a failure with no change on @a dataLength.
@return Whether succeeded.
@note The only valid operation after this is either call of @ref litePDF_SaveToDataWithSign again,
to get information about necessary buffer size or data itself, close the document
with @ref litePDF_Close, or free the context with @ref litePDF_FreeContext.
@note Signing already signed document can cause breakage of previous signatures, thus
check whether the loaded document is already signed with @ref litePDF_GetDocumentIsSigned.
Load the document with its @a forUpdate parameter set to TRUE, to sign an existing document.
@see litePDF_SaveToFileWithSign
*/
typedef void (__stdcall *litePDF_appendSignatureDataFunc)(const char *bytes,
unsigned int bytes_len,
void *user_data);
/**<
The function is used within @ref litePDF_SaveToFileWithSignManual and @ref litePDF_SaveToDataWithSignManual.
It is called called when more data should be added to hash computation.
*/
typedef void (__stdcall *litePDF_finishSignatureFunc)(char *signature,
unsigned int *signature_len,
void *user_data);
/**<
The function is used within @ref litePDF_SaveToFileWithSignManual and @ref litePDF_SaveToDataWithSignManual.
It is called when all the data are processed and the signature value is required.
The @a signature_len contains size of the @a signature buffer. The callback is
responsible to populate @a signature and @a signature_len with correct values.
Set @a signature_len to zero on any error. Note the callback is called only once.
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SaveToFileWithSignManual(void *pctx,
const char *fileName,
unsigned int signatureIndex,
litePDF_appendSignatureDataFunc appendSignatureData,
void *append_user_data,
litePDF_finishSignatureFunc finishSignature,
void *finish_user_data);
/**<
Digitally signs a PDF document opened at the litePDF context. The caller is
responsible for a detached hash computations and related certificate management.
In case the document had been loaded with @ref litePDF_LoadFromFile,
@ref litePDF_LoadFromFileW or @ref litePDF_LoadFromData with its @a forUpdate
parameter being TRUE, the resulting document will contain the changes as
an incremental update (appended at the end of the original document), otherwise
the whole document is completely rewritten.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param fileName A file name where to save signed PDF document.
@param signatureIndex Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param appendSignatureData Called when more data should be added to hash computation.
The function cannot be NULL, even when called the second time, to get actual data.
@param append_user_data User data value for the @a appendSignatureData callback.
@param finishSignature Called when all the data are processed, and the signature
value is required. The @a signature_len contains size of the @a signature buffer.
The callback is responsible to populate @a signature and @a signature_len with
correct values. Set @a signature_len to zero on any error.
Note the callback is called only once.
The function cannot be NULL, even when called the second time, to get actual data.
@param finish_user_data User data value for the @a finishSignature callback.
@return Whether succeeded.
@note The only valid operation after this is either close the document
with @ref litePDF_Close, or free the context with @ref litePDF_FreeContext.
@note Signing already signed document can cause breakage of previous signatures, thus
check whether the loaded document is already signed with @ref litePDF_GetDocumentIsSigned.
Load the document with its @a forUpdate parameter set to TRUE, to sign an existing document.
@see litePDF_SaveToFileWithSign, litePDF_SaveToFileWithSignManualW, litePDF_SaveToDataWithSignManual
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SaveToFileWithSignManualW(void *pctx,
const wchar_t *fileName,
unsigned int signatureIndex,
litePDF_appendSignatureDataFunc appendSignatureData,
void *append_user_data,
litePDF_finishSignatureFunc finishSignature,
void *finish_user_data);
/**<
This is the same as @ref litePDF_SaveToFileWithSignManual, the only difference is that
the @a fileName is a wide string.
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_SaveToDataWithSignManual(void *pctx,
unsigned int signatureIndex,
litePDF_appendSignatureDataFunc appendSignatureData,
void *append_user_data,
litePDF_finishSignatureFunc finishSignature,
void *finish_user_data,
BYTE *data,
unsigned int *dataLength);
/**<
Digitally signs a PDF document opened at the litePDF context. The caller is
responsible for a detached hash computations and related certificate management.
In case the document had been loaded with @ref litePDF_LoadFromFile,
@ref litePDF_LoadFromFileW or @ref litePDF_LoadFromData with its @a forUpdate
parameter being TRUE, the resulting document will contain the changes as
an incremental update (appended at the end of the original document), otherwise
the whole document is completely rewritten.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param signatureIndex Which signature to use; counts from 0. This might be less
than @ref litePDF_GetSignatureCount.
@param appendSignatureData Called when more data should be added to hash computation.
The function cannot be NULL, even when called the second time, to get actual data.
@param append_user_data User data value for the @a appendSignatureData callback.
@param finishSignature Called when all the data are processed, and the signature
value is required. The @a signature_len contains size of the @a signature buffer.
The callback is responsible to populate @a signature and @a signature_len with
correct values. Set @a signature_len to zero on any error.
Note the callback is called only once.
The function cannot be NULL, even when called the second time, to get actual data.
@param finish_user_data User data value for the @a finishSignature callback.
@param data [out] Actual data to store the PDF content to. It can be NULL, in which case
the @a dataLength is populated with large-enough value to hold the whole data.
@param dataLength [in/out] Tells how many bytes can be stored in @a data. If @a data
is NULL, then it is set to large-enough value. Passing non-NULL @a data with no enough
large buffer results in a failure with no change on @a dataLength.
@return Whether succeeded.
@note The only valid operation after this is either call of @ref litePDF_SaveToDataWithSignManual again,
to get information about necessary buffer size or data itself, close the document
with @ref litePDF_Close, or free the context with @ref litePDF_FreeContext.
@note Signing already signed document can cause breakage of previous signatures, thus
check whether the loaded document is already signed with @ref litePDF_GetDocumentIsSigned.
Load the document with its @a forUpdate parameter set to TRUE, to sign an existing document.
@see litePDF_SaveToFileWithSignManual, litePDF_SaveToFileWithSign
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_EmbedFile(void *pctx,
const char *fileName);
/**<
Embeds a file into a PDF document.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param fileName File name of the file to be attached.
@return Whether succeeded.
@note Files can be embed only to memory-based documents.
@note The path is stripped from the @a fileName. The @a fileName is used as a key,
aka it's not possible to embed two files of the same name into a PDF document.
@see litePDF_EmbedFileW, litePDF_EmbedData, litePDF_CreateMemDocument
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_EmbedFileW(void *pctx,
const wchar_t *fileName);
/**<
This is the same as @ref litePDF_EmbedFile, the only difference is that
the @a fileName is a wide string.
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_EmbedData(void *pctx,
const char *fileName,
const BYTE *data,
unsigned int dataLength);
/**<
Embeds a data (file) into a PDF document.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param fileName File name to be used for the data identification.
@param data Actual data to be attached.
@param dataLength Length of the data.
@return Whether succeeded.
@note Data can be embed only to memory-based documents.
@note The path is stripped from the @a fileName. The @a fileName is used as a key,
aka it's not possible to embed two files of the same name into a PDF document.
@see litePDF_EmbedDataW, litePDF_EmbedFile, litePDF_CreateMemDocument
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_EmbedDataW(void *pctx,
const wchar_t *fileName,
const BYTE *data,
unsigned int dataLength);
/**<
This is the same as @ref litePDF_EmbedData, the only difference is that
the @a fileName is a wide string.
*/
INT __stdcall LITEPDF_PUBLIC litePDF_GetEmbeddedFileCount(void *pctx);
/**<
Gets count of embedded files stored in a PDF document.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@return Count of found embedded files, or -1 on error.
@see litePDF_EmbedFile, litePDF_EmbedData, litePDF_GetEmbeddedFileName,
litePDF_GetEmbeddedFileData
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetEmbeddedFileName(void *pctx,
unsigned int index,
char *fileName,
unsigned int *fileNameLength);
/**<
Gets embedded file's name, as stored in a PDF document.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Index of the embedded file; returns failure, if out of range.
@param fileName [out] Buffer to store the embedded file's name to. It can be NULL,
in which case the @a fileNameLength is populated with large-enough value to hold
the whole string.
@param fileNameLength [in/out] Tells how many characters can be stored in @a fileName.
If @a fileName is NULL, then it is set to large-enough value. Passing
non-NULL @a fileName with no enough large buffer results in a failure with
no change on @a fileNameLength. The set length is without the Null-terminate character.
@return Whether succeeded.
@see litePDF_GetEmbeddedFileNameW, litePDF_EmbedFile, litePDF_EmbedData, litePDF_GetEmbeddedFileCount,
litePDF_GetEmbeddedFileData
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetEmbeddedFileNameW(void *pctx,
unsigned int index,
wchar_t *fileName,
unsigned int *fileNameLength);
/**<
This is the same as @ref litePDF_GetEmbeddedFileName, the only difference is that
the @a fileName is a wide string.
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_GetEmbeddedFileData(void *pctx,
unsigned int index,
BYTE *data,
unsigned int *dataLength);
/**<
Gets embedded file's data, as stored in a PDF document. There are no data returned,
if the file was not embed.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext.
@param index Index of the embedded file; returns failure, if out of range.
@param data [out] Actual embedded file's data, as stored in the PDF. It can be NULL, in which case
the @a dataLength is populated with large-enough value to hold the whole data.
@param dataLength [in/out] Tells how many bytes can be stored in @a data. If @a data
is NULL, then it is set to large-enough value. Passing non-NULL @a data with no enough
large buffer results in a failure with no change on @a dataLength.
@return Whether succeeded.
@see litePDF_EmbedFile, litePDF_EmbedData, litePDF_GetEmbeddedFileCount,
litePDF_GetEmbeddedFileName
*/
void * __stdcall LITEPDF_PUBLIC litePDF_GetPoDoFoDocument(void *pctx);
/**<
Gets a pointer to PoDoFo::PdfDocument document, which is currently opened.
The returned pointer is owned by litePDF, do not free it. It is valid until
the document is closed.
@return Pointer to currently opened PoDoFo::PdfDocument.
@see litePDF_Close
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_DrawDebugPage(void *pctx,
const char *filename);
/**<
Draws saved debugPage as a new page into the PDF file. There should not be
running any drawing when calling this function (like no page can be opened
for drawing).
@param pctx litePDF context, previously created with @ref litePDF_CreateContext.
@param filename File name with full path for litePDF debug page.
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_CreateLinkAnnotation(void *pctx,
unsigned int annotationPageIndex,
int annotationX_u,
int annotationY_u,
int annotationWidth_u,
int annotationHeight_u,
unsigned int annotationFlags,
unsigned int annotationResourceID,
unsigned int destinationPageIndex,
unsigned int destinationX_u,
unsigned int destinationY_u,
const wchar_t *destinationDescription);
/**<
Creates a link annotation at the given page and position, which will target the given
destination page and the position in it. The context should hold a memory-based document.
Note, the link annotation can be created only when the document is not drawing, to
have all the document pages available.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext,
to which add the link annotation.
@param annotationPageIndex Page index where to place the link annotation.
@param annotationX_u X-origin of the annotation on the page, in the current unit.
@param annotationY_u Y-origin of the annotation on the page, in the current unit.
@param annotationWidth_u Width of the annotation on the page, in the current unit.
@param annotationHeight_u Height of the annotation on the page, in the current unit.
@param annotationFlags Bit-or of LITEPDF_ANNOTATION_FLAG_ flags.
@param annotationResourceID Optional resource ID of the annotation content, as shown
to the user. 0 means do not add additional visualization on the page, but the annotation
can be still clicked.
@param destinationPageIndex Page index where the link points to.
@param destinationX_u X-origin of the destination on the page, in the current unit.
@param destinationY_u Y-origin of the destination on the page, in the current unit.
@param destinationDescription Optional destination description, which can be used
for accessibility reasons by the viewer.
@return Whether succeeded.
@see litePDF_GetUnit, litePDF_GetPageCount, litePDF_AddResource, litePDF_CreateBookmarkRoot
*/
BOOL __stdcall LITEPDF_PUBLIC litePDF_CreateURIAnnotation(void *pctx,
unsigned int annotationPageIndex,
int annotationX_u,
int annotationY_u,
int annotationWidth_u,
int annotationHeight_u,
unsigned int annotationFlags,
unsigned int annotationResourceID,
const char *destinationURI,
const wchar_t *destinationDescription);
/**<
Creates a URI annotation at the given page and position, which will reference the given
destination URI. The context should hold a memory-based document.
Note, the URI annotation can be created only when the document is not drawing, to
have all the document pages available.
@param pctx a litePDF context, previously created with @ref litePDF_CreateContext,
to which add the URI annotation.
@param annotationPageIndex Page index where to place the URI annotation.
@param annotationX_u X-origin of the annotation on the page, in the current unit.
@param annotationY_u Y-origin of the annotation on the page, in the current unit.
@param annotationWidth_u Width of the annotation on the page, in the current unit.
@param annotationHeight_u Height of the annotation on the page, in the current unit.
@param annotationFlags Bit-or of LITEPDF_ANNOTATION_FLAG_ flags.
@param annotationResourceID Optional resource ID of the annotation content, as shown
to the user. 0 means do not add additional visualization on the page, but the annotation
can be still clicked.
@param destinationURI The URI the annotation points to.
@param destinationDescription Optional destination description, which can be used
for accessibility reasons by the viewer.
@return Whether succeeded.
@see litePDF_GetUnit, litePDF_GetPageCount, litePDF_AddResource
*/
#define LITEPDF_BOOKMARK_FLAG_NONE 0x0000 /**< Default bookmark flags */
#define LITEPDF_BOOKMARK_FLAG_ITALIC 0x0001 /**< Show bookmark title as an italic text */
#define LITEPDF_BOOKMARK_FLAG_BOLD 0x0002 /**< Show bookmark title as a bold text */
unsigned int __stdcall LITEPDF_PUBLIC litePDF_CreateBookmarkRoot(void *pctx,
const wchar_t *title,
unsigned int flags,
unsigned char titleColor_red,
unsigned char titleColor_green,
unsigned char titleColor_blue,
unsigned int destinationPageIndex,
unsigned int destinationX_u,
unsigned int destinationY_u);
/**<
Creates a new root (top-level) bookmark, which will target the given destination
page and the position in it. The context should hold a memory-based document.
Note, the bookmarks can be created only when the document is not drawing, to
have all the document pages available.
@param pctx A litePDF context, previously created with @ref litePDF_CreateContext,
to which add the link annotation.
@param title Title of the bookmark.
@param flags Bit-or of LITEPDF_BOOKMARK_FLAG_ flags.
@param titleColor_red RGB red value of the title text color.
@param titleColor_green RGB green value of the title text color.
@param titleColor_blue RGB blue value of the title text color.
@param destinationPageIndex Page index where the link points to.
@param destinationX_u X-origin of the destination on the page, in the current unit.
@param destinationY_u Y-origin of the destination on the page, in the current unit.
@return Created bookmark ID or 0, when the bookmark could not be created.
@see litePDF_GetUnit, litePDF_CreateBookmarkChild, litePDF_CreateBookmarkSibling, litePDF_CreateLinkAnnotation
*/
unsigned int __stdcall LITEPDF_PUBLIC litePDF_CreateBookmarkChild(void *pctx,
unsigned int parentBookmarkID,
const wchar_t *title,
unsigned int flags,
unsigned char titleColor_red,
unsigned char titleColor_green,
unsigned char titleColor_blue,
unsigned int destinationPageIndex,
unsigned int destinationX_u,
unsigned int destinationY_u);
/**<
Creates a new child bookmark, which will target the given destination
page and the position in it. The context should hold a memory-based document.
Note, the bookmarks can be created only when the document is not drawing, to
have all the document pages available.
@param pctx A litePDF context, previously created with @ref litePDF_CreateContext,
to which add the link annotation.
@param parentBookmarkID Bookmark ID of the parent bookmark. The child will be
created under this bookmark.
@param title Title of the bookmark.
@param flags Bit-or of LITEPDF_BOOKMARK_FLAG_ flags.
@param titleColor_red RGB red value of the title text color.
@param titleColor_green RGB green value of the title text color.
@param titleColor_blue RGB blue value of the title text color.
@param destinationPageIndex Page index where the link points to.
@param destinationX_u X-origin of the destination on the page, in the current unit.
@param destinationY_u Y-origin of the destination on the page, in the current unit.
@return Created bookmark ID or 0, when the bookmark could not be created.
@see litePDF_GetUnit, litePDF_CreateBookmarkRoot, litePDF_CreateBookmarkSibling, litePDF_CreateLinkAnnotation
*/
unsigned int __stdcall LITEPDF_PUBLIC litePDF_CreateBookmarkSibling(void *pctx,
unsigned int previousBookmarkID,
const wchar_t *title,
unsigned int flags,
unsigned char titleColor_red,
unsigned char titleColor_green,
unsigned char titleColor_blue,
unsigned int destinationPageIndex,
unsigned int destinationX_u,
unsigned int destinationY_u);
/**<
Creates a new sibling (next) bookmark, which will target the given destination
page and the position in it. The context should hold a memory-based document.
Note, the bookmarks can be created only when the document is not drawing, to
have all the document pages available.
@param pctx A litePDF context, previously created with @ref litePDF_CreateContext,
to which add the link annotation.
@param previousBookmarkID Bookmark ID of the previous bookmark. The sibling will be
created as the next of this bookmark.
@param title Title of the bookmark.
@param flags Bit-or of LITEPDF_BOOKMARK_FLAG_ flags.
@param titleColor_red RGB red value of the title text color.
@param titleColor_green RGB green value of the title text color.
@param titleColor_blue RGB blue value of the title text color.
@param destinationPageIndex Page index where the link points to.
@param destinationX_u X-origin of the destination on the page, in the current unit.
@param destinationY_u Y-origin of the destination on the page, in the current unit.
@return Created bookmark ID or 0, when the bookmark could not be created.
@see litePDF_GetUnit, litePDF_CreateBookmarkRoot, litePDF_CreateBookmarkChild, litePDF_CreateLinkAnnotation
*/
LITEPDF_END_DECLS
#endif /* LITEPDF_H */