litePDF C++ interface  2.0.5
Public Member Functions | List of all members
litePDF::TLitePDF Class Reference

#include <litePDF.h>

Public Member Functions

 TLitePDF ()
 
virtual ~TLitePDF ()
 
void setOnError (MLitePDFErrorEvent pOnError, void *pOnErrorUserData)
 
DWORD getLastErrorCode (void) const
 
const char * getLastErrorMessage (void) const
 
void SetUnit (TLitePDFUnit unitValue)
 
TLitePDFUnit GetUnit (void)
 
double MMToUnitEx (TLitePDFUnit useUnit, double mmValue) const
 
double UnitToMMEx (TLitePDFUnit useUnit, double unitValue) const
 
double InchToUnitEx (TLitePDFUnit useUnit, double inchValue) const
 
double UnitToInchEx (TLitePDFUnit useUnit, double unitValue) const
 
double MMToUnit (double mmValue)
 
double UnitToMM (double unitValue)
 
double InchToUnit (double inchValue)
 
double UnitToInch (double unitValue)
 
void SetEvalFontFlagCallback (TLitePDFEvalFontFlagCB callback, void *userData)
 
void PrepareEncryption (const char *userPassword, const char *ownerPassword, unsigned int permissions, unsigned int algorithm)
 
void CreateFileDocument (const char *fileName)
 
void CreateFileDocumentW (const wchar_t *fileName)
 
void CreateMemDocument (void)
 
void LoadFromFile (const char *fileName, const char *password, bool loadCompletely, bool forUpdate=false)
 
void LoadFromFileW (const wchar_t *fileName, const char *password, bool loadCompletely, bool forUpdate=false)
 
void LoadFromData (const BYTE *data, unsigned int dataLength, const char *password, bool forUpdate=false)
 
void SaveToFile (const char *fileName)
 
void SaveToFileW (const wchar_t *fileName)
 
bool SaveToData (BYTE *data, unsigned int *dataLength)
 
void Close (void)
 
unsigned int GetPageCount (void)
 
void GetPageSize (unsigned int pageIndex, unsigned int *width_u, unsigned int *height_u)
 
int GetPageRotation (unsigned int pageIndex)
 
void SetPageRotation (unsigned int pageIndex, int degrees)
 
HDC AddPage (unsigned int width_u, unsigned int height_u, unsigned int width_px, unsigned int height_px, unsigned int drawFlags)
 
HDC InsertPage (unsigned int pageIndex, unsigned int width_u, unsigned int height_u, unsigned int width_px, unsigned int height_px, unsigned int drawFlags)
 
HDC UpdatePage (unsigned int pageIndex, unsigned int width_px, unsigned int height_px, unsigned int drawFlags)
 
void FinishPage (HDC hDC)
 
HDC AddResource (unsigned int width_u, unsigned int height_u, unsigned int width_px, unsigned int height_px, unsigned int drawFlags)
 
unsigned int FinishResource (HDC hDC)
 
void DeletePage (unsigned int pageIndex)
 
void AddPagesFrom (litePDF::TLitePDF *from, unsigned int pageIndex, unsigned int pageCount)
 
void InsertPageFrom (unsigned int pageIndexTo, litePDF::TLitePDF *from, unsigned int pageIndexFrom)
 
unsigned int AddPageFromAsResource (litePDF::TLitePDF *from, unsigned int pageIndex, bool useTrimBox=false)
 
unsigned int PageToResource (unsigned int pageIndex)
 
void GetResourceSize (unsigned int resourceID, unsigned int *width_u, unsigned int *height_u)
 
void DrawResource (unsigned int resourceID, unsigned int pageIndex, TLitePDFUnit unitValue, int x, int y, int scaleX, int scaleY)
 
void DrawResourceWithMatrix (unsigned int resourceID, unsigned int pageIndex, double a, double b, double c, double d, double e, double f)
 
void SetDocumentInfo (const char *name, const wchar_t *value)
 
bool GetDocumentInfoExists (const char *name)
 
std::wstring GetDocumentInfo (const char *name)
 
bool GetDocumentIsSigned (void)
 
unsigned int GetSignatureCount (void)
 
std::string GetSignatureName (unsigned int index)
 
unsigned int CreateSignature (const char *name, unsigned int annotationPageIndex, int annotationX_u, int annotationY_u, int annotationWidth_u, int annotationHeight_u, unsigned int annotationFlags)
 
bool GetSignatureHasData (unsigned int index)
 
bool GetSignatureData (unsigned int index, BYTE *data, unsigned int *dataLength)
 
bool GetSignatureRanges (unsigned int index, unsigned __int64 *pRangesArray, unsigned int *pRangesArrayLength)
 
void SetSignatureDate (unsigned int index, __int64 dateOfSign)
 
__int64 GetSignatureDate (unsigned int index)
 
void SetSignatureReason (unsigned int index, const wchar_t *reason)
 
std::wstring GetSignatureReason (unsigned int index)
 
void SetSignatureLocation (unsigned int index, const wchar_t *location)
 
std::wstring GetSignatureLocation (unsigned int index)
 
void SetSignatureCreator (unsigned int index, const char *creator)
 
std::string GetSignatureCreator (unsigned int index)
 
void SetSignatureAppearance (unsigned int index, TLitePDFAppearance appearanceType, unsigned int resourceID, int offsetX_u, int offsetY_u)
 
void SetSignatureCertification (unsigned int index, TLitePDFCertificationPermission permission)
 
void SetSignatureSize (unsigned int requestBytes)
 
void SetSignatureHash (TLitePDFSignatureHash signatureHash)
 
void AddSignerPFX (const BYTE *pfxData, unsigned int pfxDataLength, const char *pfxPassword)
 
void AddSignerPEM (const BYTE *pemData, unsigned int pemDataLength, const BYTE *pkeyData, unsigned int pkeyDataLength, const char *pkeyPassword)
 
void SaveToFileWithSign (const char *fileName, unsigned int signatureIndex)
 
void SaveToFileWithSignW (const wchar_t *fileName, unsigned int signatureIndex)
 
bool SaveToDataWithSign (unsigned int signatureIndex, BYTE *data, unsigned int *dataLength)
 
void SaveToFileWithSignManual (const char *fileName, unsigned int signatureIndex, TLitePDFAppendSignatureDataFunc appendSignatureData, void *append_user_data, TLitePDFFinishSignatureFunc finishSignature, void *finish_user_data)
 
void SaveToFileWithSignManualW (const wchar_t *fileName, unsigned int signatureIndex, TLitePDFAppendSignatureDataFunc appendSignatureData, void *append_user_data, TLitePDFFinishSignatureFunc finishSignature, void *finish_user_data)
 
bool SaveToDataWithSignManual (unsigned int signatureIndex, TLitePDFAppendSignatureDataFunc appendSignatureData, void *append_user_data, TLitePDFFinishSignatureFunc finishSignature, void *finish_user_data, BYTE *data, unsigned int *dataLength)
 
void EmbedFile (const char *fileName)
 
void EmbedFileW (const wchar_t *fileName)
 
void EmbedData (const char *fileName, const BYTE *data, unsigned int dataLength)
 
void EmbedDataW (const wchar_t *fileName, const BYTE *data, unsigned int dataLength)
 
int GetEmbeddedFileCount (void)
 
std::string GetEmbeddedFileName (unsigned int index)
 
std::wstring GetEmbeddedFileNameW (unsigned int index)
 
bool GetEmbeddedFileData (unsigned int index, BYTE *data, unsigned int *dataLength)
 
void * GetPoDoFoDocument (void)
 
void DrawDebugPage (const char *filename)
 
void CreateLinkAnnotation (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)
 
void CreateURIAnnotation (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)
 
unsigned int CreateBookmarkRoot (const wchar_t *title, unsigned int flags, COLORREF titleColor, unsigned int destinationPageIndex, unsigned int destinationX_u, unsigned int destinationY_u)
 
unsigned int CreateBookmarkChild (unsigned int parentBookmarkID, const wchar_t *title, unsigned int flags, COLORREF titleColor, unsigned int destinationPageIndex, unsigned int destinationX_u, unsigned int destinationY_u)
 
unsigned int CreateBookmarkSibling (unsigned int previousBookmarkID, const wchar_t *title, unsigned int flags, COLORREF titleColor, unsigned int destinationPageIndex, unsigned int destinationX_u, unsigned int destinationY_u)
 

Constructor & Destructor Documentation

litePDF::TLitePDF::TLitePDF ( )

Creates a new TLiteDPF object.

Note
The library is not thread safe, thus if there is any need for the thread safety, then the caller is responsible to provide it on its own.
virtual litePDF::TLitePDF::~TLitePDF ( )
virtual

Member Function Documentation

HDC litePDF::TLitePDF::AddPage ( unsigned int  width_u,
unsigned int  height_u,
unsigned int  width_px,
unsigned int  height_px,
unsigned int  drawFlags 
)

Begins drawing into a new page into the PDF document of the given size. Newly created page is added as the last page of the PDF document. This cannot be called when other drawing is in progress.

Parameters
width_uWidth of the new page in the current unit.
height_uHeight of the new page in the current unit.
width_pxWidth of the new page in pixels.
height_pxHeight of the new page in pixels.
drawFlagsFlags for drawing functions. This is a bit-or of TLitePDFDrawFlags values and influences only AddPage, InsertPage, UpdatePage and AddResource functions.
Returns
Device context into which can be drawn with standard GDI functions. Finish the drawing, and the page addition, with FinishPage.
Note
Larger pixel page size produces more precise font mapping.
See Also
GetUnit, InsertPage, UpdatePage, FinishPage, AddResource
unsigned int litePDF::TLitePDF::AddPageFromAsResource ( litePDF::TLitePDF from,
unsigned int  pageIndex,
bool  useTrimBox = false 
)

Adds an existing page as a resource of a given PDF. This resource can be referenced multiple times by its identifier. Both objects should hold memory-based documents.

Parameters
froma LitePDF object, from which add the page.
pageIndexPage index which to add from from; counts from 0.
useTrimBoxIf true, try to use trimbox for size of the resource (XObject)
Returns
Resource identifier, or 0 on error.
Note
The two objects cannot be the same.
See Also
GetPageCount, AddPagesFrom, PageToResource, GetResourceSize, DrawResource
void litePDF::TLitePDF::AddPagesFrom ( litePDF::TLitePDF from,
unsigned int  pageIndex,
unsigned int  pageCount 
)

Adds existing pages as the last pages from another PDF. Both objects should hold memory-based documents.

Parameters
froma LitePDF object from which add the pages.
pageIndexPage index which to add from from; counts from 0.
pageCountHow many pages to add; 0 means whole document.
Note
The two objects cannot be the same.
See Also
GetPageCount, InsertPageFrom, PageToResource
HDC litePDF::TLitePDF::AddResource ( unsigned int  width_u,
unsigned int  height_u,
unsigned int  width_px,
unsigned int  height_px,
unsigned int  drawFlags 
)

Begins drawing into a new resource into the PDF document of the given size. This cannot be called when other drawing is in progress.

Parameters
width_uWidth of the new page in the current unit.
height_uHeight of the new page in the current unit.
width_pxWidth of the new page in pixels.
height_pxHeight of the new page in pixels.
drawFlagsFlags for drawing functions. This is a bit-or of TLitePDFDrawFlags values and influences only AddPage, InsertPage, UpdatePage and AddResource functions.
Returns
Device context into which can be drawn with standard GDI functions. Finish the drawing, and the resource addition, with FinishResource.
Note
Larger pixel resource size produces more precise font mapping.
See Also
GetUnit, AddPage, InsertPage, UpdatePage, FinishResource, DrawResource
void litePDF::TLitePDF::AddSignerPEM ( 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 SaveToFileWithSign or SaveToDataWithSign. The passed-in certificate and private key are in the PEM format.

Parameters
pemDataA certificate in the PEM format.
pemDataLengthA length of the pemData.
pkeyDataA private key for the certificate, in the PEM format.
pkeyDataLengthA length of the pkeyData.
pkeyPasswordA password to use to open the private key; can be NULL.
See Also
AddSignerPFX
void litePDF::TLitePDF::AddSignerPFX ( const BYTE *  pfxData,
unsigned int  pfxDataLength,
const char *  pfxPassword 
)

Adds a signer to be used when digitally signing the document with SaveToFileWithSign or SaveToDataWithSign. The passed-in certificate is in the PFX format and should include the private key.

Parameters
pfxDataA certificate with private key in the PFX format.
pfxDataLengthA length of the pfxData.
pfxPasswordA password to use to open the PFX certificate; can be NULL.
See Also
AddSignerPEM
void litePDF::TLitePDF::Close ( void  )

Closes PDF data in a LitePDF object, thus the object doesn't hold anything afterward, aka it's like a newly created object. The function does nothing, if the object doesn't hold any data. In case of any drawing in progress, the drawing is discarded, same as any unsaved changes to the memory-based PDF documents. It also unsets any encryption properties, previously set by PrepareEncryption.

See Also
AddPage, InsertPage, UpdatePage, FinishPage
unsigned int litePDF::TLitePDF::CreateBookmarkChild ( unsigned int  parentBookmarkID,
const wchar_t *  title,
unsigned int  flags,
COLORREF  titleColor,
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 object 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.

Parameters
parentBookmarkIDBookmark ID of the parent bookmark. The child will be created under this bookmark.
titleTitle of the bookmark.
flagsBit-or of TLitePDFBookmarkFlags flags.
titleColorRGB value of the title text color.
destinationPageIndexPage index where the link points to.
destinationX_uX-origin of the destination on the page, in the current unit.
destinationY_uY-origin of the destination on the page, in the current unit.
Returns
Created bookmark ID or 0, when the bookmark could not be created.
See Also
GetUnit, CreateBookmarkRoot, CreateBookmarkSibling, CreateLinkAnnotation
unsigned int litePDF::TLitePDF::CreateBookmarkRoot ( const wchar_t *  title,
unsigned int  flags,
COLORREF  titleColor,
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 object 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.

Parameters
titleTitle of the bookmark.
flagsBit-or of TLitePDFBookmarkFlags flags.
titleColorRGB value of the title text color.
destinationPageIndexPage index where the link points to.
destinationX_uX-origin of the destination on the page, in the current unit.
destinationY_uY-origin of the destination on the page, in the current unit.
Returns
Created bookmark ID or 0, when the bookmark could not be created.
See Also
GetUnit, CreateBookmarkChild, CreateBookmarkSibling, CreateLinkAnnotation
unsigned int litePDF::TLitePDF::CreateBookmarkSibling ( unsigned int  previousBookmarkID,
const wchar_t *  title,
unsigned int  flags,
COLORREF  titleColor,
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 object 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.

Parameters
previousBookmarkIDBookmark ID of the previous bookmark. The sibling will be created as the next of this bookmark.
titleTitle of the bookmark.
flagsBit-or of TLitePDFBookmarkFlags flags.
titleColorRGB value of the title text color.
destinationPageIndexPage index where the link points to.
destinationX_uX-origin of the destination on the page, in the current unit.
destinationY_uY-origin of the destination on the page, in the current unit.
Returns
Created bookmark ID or 0, when the bookmark could not be created.
See Also
CreateBookmarkRoot, CreateBookmarkChild, CreateLinkAnnotation
void litePDF::TLitePDF::CreateFileDocument ( const char *  fileName)

Makes the LitePDF object hold a new PDF, which writes directly to a file. The object should not have opened any other PDF data. Call Close, to close the file, and possibly save changes to it. Most of the operations require memory-based PDF, which can be created with CreateMemDocument.

Parameters
fileNameFile name to write the PDF result to.
Note
PoDoFo doesn't support creation of file-based documents with AES encryption, thus use for it memory-based documents instead (CreateMemDocument).
See Also
PrepareEncryption, CreateFileDocumentW, CreateMemDocument, LoadFromFile
void litePDF::TLitePDF::CreateFileDocumentW ( const wchar_t *  fileName)

This is the same as CreateFileDocument, the only difference is that the fileName is a wide string.

void litePDF::TLitePDF::CreateLinkAnnotation ( 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 object 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.

Parameters
annotationPageIndexPage index where to place the link annotation.
annotationX_uX-origin of the annotation on the page, in the current unit.
annotationY_uY-origin of the annotation on the page, in the current unit.
annotationWidth_uWidth of the annotation on the page, in the current unit.
annotationHeight_uHeight of the annotation on the page, in the current unit.
annotationFlagsBit-or of TLitePDFAnnotationFlags flags.
annotationResourceIDOptional 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.
destinationPageIndexPage index where the link points to.
destinationX_uX-origin of the destination on the page, in the current unit.
destinationY_uY-origin of the destination on the page, in the current unit.
destinationDescriptionOptional destination description, which can be used for accessibility reasons by the viewer.
See Also
GetUnit, GetPageCount, AddResource, CreateBookmarkRoot
void litePDF::TLitePDF::CreateMemDocument ( void  )

Makes the litePDF object hold a memory-based PDF. Such PDF can be saved with SaveToFile or SaveToData. The PDF should be closed with Close.

See Also
PrepareEncryption, CreateFileDocument, LoadFromFile
unsigned int litePDF::TLitePDF::CreateSignature ( const char *  name,
unsigned int  annotationPageIndex,
int  annotationX_u,
int  annotationY_u,
int  annotationWidth_u,
int  annotationHeight_u,
unsigned int  annotationFlags 
)

Creates a new signature field named name. The field is created completely empty. Use SetSignatureDate, SetSignatureReason, SetSignatureLocation, SetSignatureCreator, SetSignatureAppearance and such to populate it with required values. Finally, to sign the signature field use SaveToFileWithSign family functions.

Parameters
nameSignature field name to use. This should be unique.
annotationPageIndexPage index where to place the signature annotation.
annotationX_uX-origin of the annotation on the page, in the current unit.
annotationY_uY-origin of the annotation on the page, in the current unit.
annotationWidth_uWidth of the annotation on the page, in the current unit.
annotationHeight_uHeight of the annotation on the page, in the current unit.
annotationFlagsBit-or of TLitePDFAnnotationFlags flags.
Returns
The index of the added signature field.
See Also
GetSignatureCount, GetSignatureName
void litePDF::TLitePDF::CreateURIAnnotation ( 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.

Parameters
annotationPageIndexPage index where to place the URI annotation.
annotationX_uX-origin of the annotation on the page, in the current unit.
annotationY_uY-origin of the annotation on the page, in the current unit.
annotationWidth_uWidth of the annotation on the page, in the current unit.
annotationHeight_uHeight of the annotation on the page, in the current unit.
annotationFlagsBit-or of TLitePDFAnnotationFlags flags.
annotationResourceIDOptional 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.
destinationURIThe URI the annotation points to.
destinationDescriptionOptional destination description, which can be used for accessibility reasons by the viewer.
See Also
GetUnit, GetPageCount, AddResource
void litePDF::TLitePDF::DeletePage ( unsigned int  pageIndex)

Deletes page at given index. It doesn't delete page resources, because these can be used by other pages.

Parameters
pageIndexPage index which to update; counts from 0.
Returns
Whether succeeded.
See Also
GetPageCount, PageToResource
void litePDF::TLitePDF::DrawDebugPage ( 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).

Parameters
filenameFile name with full path for litePDF debug page.
void litePDF::TLitePDF::DrawResource ( unsigned int  resourceID,
unsigned int  pageIndex,
TLitePDFUnit  unitValue,
int  x,
int  y,
int  scaleX,
int  scaleY 
)

Draws an existing resource at the given position. The resource ID was returned from AddPageFromAsResource, PageToResource or FinishResource. The unitValue is used for both the position and the scale. In case of the scale, it defines only the ratio to the base unit. For example, if the unitValue is either LitePDFUnit_1000th_mm or LitePDFUnit_1000th_inch, then the ratio for the scaleX and scaleY is used 1/1000 (where 1000 means the same size as the resource is in this case).

Parameters
resourceIDResource ID to draw.
pageIndexPage index to which draw; counts from 0.
unitValueA unit to use for the x and y, and a ratio for the scaleX and scaleY.
xWhere to draw on the page, X axes, in the given unitValue unit, with left-top corner being [0,0].
yWhere to draw on the page, Y axes, in the given unitValue unit, with left-top corner being [0,0].
scaleXScale factor of the page for the X axes, using the unitValue ratio.
scaleYScale factor of the page for the Y axes, using the unitValue ratio.
See Also
GetPageCount, AddPageFromAsResource, PageToResource, FinishResource, GetResourceSize, DrawResourceWithMatrix
void litePDF::TLitePDF::DrawResourceWithMatrix ( unsigned int  resourceID,
unsigned int  pageIndex,
double  a,
double  b,
double  c,
double  d,
double  e,
double  f 
)

Draws an existing resource with given transformation matrix. All the transformation values are passed into PDF directly, without any conversion. The resource ID was returned from AddPageFromAsResource or FinishResource. The constructed transformation matrix is a standard 3x3 matrix:
| a b 0 |
| c d 0 |
| e f 1 |

Parameters
resourceIDResource ID to draw.
pageIndexPage index to which draw; counts from 0.
aTransformation matrix [ a b c d e f ] parameter 'a', in PDF units.
bTransformation matrix [ a b c d e f ] parameter 'b', in PDF units.
cTransformation matrix [ a b c d e f ] parameter 'c', in PDF units.
dTransformation matrix [ a b c d e f ] parameter 'd', in PDF units.
eTransformation matrix [ a b c d e f ] parameter 'e', in PDF units.
fTransformation matrix [ a b c d e f ] parameter 'f', in PDF units.
Note
Each of a, b, c, d, e, f is rounded down to nearest 1/1000th of PDF units.
See Also
GetPageCount, AddPageFromAsResource, FinishResource, GetResourceSize, DrawResource
void litePDF::TLitePDF::EmbedData ( const char *  fileName,
const BYTE *  data,
unsigned int  dataLength 
)

Embeds a data (file) into a PDF document.

Parameters
fileNameFile name to be used for the data identification.
dataActual data to be attached.
dataLengthLength of the data.
Note
Data can be embed only to memory-based documents.
The path is stripped from the fileName. The fileName is used as a key, aka it's not possible to embed two files of the same name into a PDF document.
See Also
EmbedDataW, EmbedFile, CreateMemDocument
void litePDF::TLitePDF::EmbedDataW ( const wchar_t *  fileName,
const BYTE *  data,
unsigned int  dataLength 
)

This is the same as EmbedData, the only difference is that the fileName is a wide string.

void litePDF::TLitePDF::EmbedFile ( const char *  fileName)

Embeds a file into a PDF document.

Parameters
fileNameFile name of the file to be attached.
Returns
Whether succeeded.
Note
Files can be embed only to memory-based documents.
The path is stripped from the fileName. The fileName is used as a key, aka it's not possible to embed two files of the same name into a PDF document.
See Also
EmbedFileW, EmbedData, CreateMemDocument
void litePDF::TLitePDF::EmbedFileW ( const wchar_t *  fileName)

This is the same as EmbedFile, the only difference is that the fileName is a wide string.

void litePDF::TLitePDF::FinishPage ( HDC  hDC)

Tells litePDF that drawing into the page is finished and that it can be processed into PDF. The hDC is not valid after this call any more.

Parameters
hDCDevice context previously returned by AddPage, InsertPage or UpdatePage.
unsigned int litePDF::TLitePDF::FinishResource ( HDC  hDC)

Tells litePDF that drawing into the resource is finished and that it can be processed into PDF. The hDC is not valid after this call any more.

Parameters
hDCDevice context previously returned by AddResource.
Returns
Newly created resource ID, or 0 on error.
See Also
AddResource, AddPageFromAsResource, DrawResource
std::wstring litePDF::TLitePDF::GetDocumentInfo ( const char *  name)

Gets information about the document. The name can be one of the LitePDFDocumentInfo predefined constants.

Parameters
nameDocument info property name to get.
Returns
Unicode value.
bool litePDF::TLitePDF::GetDocumentInfoExists ( const char *  name)

Checks whether information about the document of the given name exists. The name can be one of the LitePDFDocumentInfo predefined constants.

Parameters
nameDocument info property name to test.
Returns
Whether succeeded and the document information is set.
bool litePDF::TLitePDF::GetDocumentIsSigned ( void  )

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.

Returns
Whether the opened document is already signed.
See Also
GetSignatureCount, SaveToFileWithSign, SaveToDataWithSign
int litePDF::TLitePDF::GetEmbeddedFileCount ( void  )

Gets count of embedded files stored in a PDF document.

Returns
Count of found embedded files, or -1 on error.
See Also
EmbedFile, EmbedData, GetEmbeddedFileName, GetEmbeddedFileData
bool litePDF::TLitePDF::GetEmbeddedFileData ( 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.

Parameters
indexIndex of the embedded file; returns failure, if out of range.
data[out] Actual embedded file's data, as stored in the PDF. It can be NULL, in which case the dataLength is populated with large-enough value to hold the whole data.
dataLength[in/out] Tells how many bytes can be stored in data. If data is NULL, then it is set to large-enough value. Passing non-NULL data with no enough large buffer results in a failure with no change on dataLength.
Returns
Whether succeeded.
See Also
EmbedFile, EmbedData, GetEmbeddedFileCount, GetEmbeddedFileName
std::string litePDF::TLitePDF::GetEmbeddedFileName ( unsigned int  index)

Gets embedded file's name, as stored in a PDF document.

Parameters
indexIndex of the embedded file; returns failure, if out of range.
Returns
File's name, as stored in a PDF document.
See Also
GetEmbeddedFileNameW, EmbedFile, EmbedData, GetEmbeddedFileCount, GetEmbeddedFileData
std::wstring litePDF::TLitePDF::GetEmbeddedFileNameW ( unsigned int  index)

This is the same as GetEmbeddedFileName, the only difference is that the return fileName is a wide string.

DWORD litePDF::TLitePDF::getLastErrorCode ( void  ) const

Returns the last error code, which was notified by the litePDF library, if any. Most of the object calls usually throw a TLitePDFException on errors.

Returns
The last error code, or 0, if there was none.
See Also
setOnError, getLastErrorMessage
const char* litePDF::TLitePDF::getLastErrorMessage ( void  ) const

Returns the last error message, which was notified by the litePDF library, if any. Most of the object calls usually throw a TLitePDFException on errors.

Returns
The last error message, or NULL, if there was none.
See Also
setOnError, getLastErrorCode
unsigned int litePDF::TLitePDF::GetPageCount ( void  )

Returns count of pages in an opened PDF document.

Returns
Count of pages.
int litePDF::TLitePDF::GetPageRotation ( unsigned int  pageIndex)

Gets rotation of an existing page, in degrees. Expected values are 0, 90, 180 and 270.

Parameters
pageIndexPage index for which get the page size; counts from 0.
Returns
Rotation of the page, in degrees.
See Also
SetPageRotation
void litePDF::TLitePDF::GetPageSize ( unsigned int  pageIndex,
unsigned int *  width_u,
unsigned int *  height_u 
)

Gets size of an existing page, in the current unit.

Parameters
pageIndexPage index for which get the page size; counts from 0.
width_u[out] Width of the page in the current unit.
height_u[out] Height of the page in the current unit.
See Also
GetUnit
void* litePDF::TLitePDF::GetPoDoFoDocument ( void  )

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.

Returns
Pointer to currently opened PoDoFo::PdfDocument.
See Also
Close
void litePDF::TLitePDF::GetResourceSize ( unsigned int  resourceID,
unsigned int *  width_u,
unsigned int *  height_u 
)

Gets size of an existing resource, in the current unit. The resource ID was returned from AddPageFromAsResource or FinishResource.

Parameters
resourceIDResource ID for which get the size.
width_u[out] Width of the resource, in the current unit.
height_u[out] Height of the resource, in the current unit.
See Also
GetUnit, AddPageFromAsResource, DrawResource
unsigned int litePDF::TLitePDF::GetSignatureCount ( void  )

Provides how many signature fields the currently opened document contains. It returns the count of the all fields, not only those already signed.

Returns
How many signatures the currently opened document contains.
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 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 Also
GetDocumentIsSigned, GetSignatureHasData, GetSignatureData
std::string litePDF::TLitePDF::GetSignatureCreator ( unsigned int  index)

Gets signature creator.

Parameters
indexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
Returns
An ASCII string containing the value.
See Also
SetSignatureCreator, GetSignatureCount
bool litePDF::TLitePDF::GetSignatureData ( unsigned int  index,
BYTE *  data,
unsigned int *  dataLength 
)

Gathers raw signature data for the given signature in the currently opened document. Use GetSignatureHasData to check whether the given signature field is signed or not.

Parameters
indexWhich signature data to get; counts from 0. This might be less than GetSignatureCount.
data[out] Actual data to store the signature content to. It can be NULL, in which case the dataLength is populated with large-enough value to hold the whole data.
dataLength[in/out] Tells how many bytes can be stored in data. If data is NULL, then it is set to large-enough value. Passing non-NULL data with no enough large buffer results in a failure with no change on dataLength.
Returns
Whether succeeded.
See Also
GetDocumentIsSigned, GetSignatureCount, GetSignatureRanges
__int64 litePDF::TLitePDF::GetSignatureDate ( unsigned int  index)

Gets signature field date of sign.

Parameters
indexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
Returns
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.
See Also
SetSignatureDate, GetSignatureCount
bool litePDF::TLitePDF::GetSignatureHasData ( unsigned int  index)

Checks whether the given signature field contains any data, which means whether the signature field is signed.

Parameters
indexWhich signature data to get; counts from 0. This might be less than GetSignatureCount.
Returns
Whether the given signature contains any data.
See Also
GetSignatureData
std::wstring litePDF::TLitePDF::GetSignatureLocation ( unsigned int  index)

Gets signature location.

Parameters
indexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
Returns
A Unicode string containing the value.
See Also
SetSignatureLocation, GetSignatureCount
std::string litePDF::TLitePDF::GetSignatureName ( unsigned int  index)

Gets the signature field name at the given index.

Parameters
indexWhich signature field name to get; counts from 0. This might be less than GetSignatureCount.
Returns
An ASCII name of the field.
bool litePDF::TLitePDF::GetSignatureRanges ( 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 (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.

Parameters
indexWhich signature ranges to get; counts from 0. This might be less than GetSignatureCount.
pRangesArray[out] Actual array to store the signature ranges to. It can be NULL, in which case the pRangesArrayLength is populated with large-enough value to hold the whole array.
pRangesArrayLength[in/out] Tells how many items can be stored in pRangesArray. If pRangesArray is NULL, then it is set to large-enough value. Passing non-NULL pRangesArray with no enough large array results in a failure with no change on pRangesArrayLength.
Returns
Whether succeeded.
Note
This function works only for the signatures which use this kind of signature method.
See Also
GetDocumentIsSigned, GetSignatureCount, GetSignatureData
std::wstring litePDF::TLitePDF::GetSignatureReason ( unsigned int  index)

Gets signature reason.

Parameters
indexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
Returns
A Unicode string containing the value.
See Also
SetSignatureReason, GetSignatureCount
TLitePDFUnit litePDF::TLitePDF::GetUnit ( void  )

Gets the currently set unit, which is used in functions which expect non-pixel size and position values. It can be one of TLitePDFUnit values. The default is LitePDFUnit_mm.

Returns
One of TLitePDFUnit values, which is set as the current unit.
See Also
Units, SetUnit, MMToUnit, UnitToMM, InchToUnit, UnitToInch
double litePDF::TLitePDF::InchToUnit ( double  inchValue)

Converts a value from inches to the current unit. The caller does the rounding as needed.

Parameters
inchValueA value in inches to convert to the current unit.
Returns
The inchValue converted to the current unit.
See Also
GetUnit, UnitToInch, MMToUnit, UnitToMM, InchToUnitEx
double litePDF::TLitePDF::InchToUnitEx ( TLitePDFUnit  useUnit,
double  inchValue 
) const

Converts a value from inches to useUnit. The caller does the rounding as needed.

Parameters
useUnitThe TLitePDFUnit unit to convert the value to.
inchValueThe value in inches to convert.
Returns
The inchValue converted to useUnit unit.
See Also
UnitToInchEx, MMToUnitEx, UnitToMMEx, InchToUnit
HDC litePDF::TLitePDF::InsertPage ( unsigned int  pageIndex,
unsigned int  width_u,
unsigned int  height_u,
unsigned int  width_px,
unsigned int  height_px,
unsigned int  drawFlags 
)

Begins drawing into a new page into the PDF document of the given size. Newly created page is inserted at the given position of the PDF document. This cannot be called when other drawing is in progress. If the index is out of bounds, then the page is added ad the end, like with AddPage.

Parameters
pageIndexPage index where to insert the page; counts from 0.
width_uWidth of the new page in the current unit.
height_uHeight of the new page in the current unit.
width_pxWidth of the new page in pixels.
height_pxHeight of the new page in pixels.
drawFlagsFlags for drawing functions. This is a bit-or of TLitePDFDrawFlags values and influences only AddPage, InsertPage, UpdatePage and AddResource functions.
Returns
Device context into which can be drawn with standard GDI functions. Finish the drawing, and the page insertion, with FinishPage.
Note
Larger pixel page size produces more precise font mapping.
See Also
GetUnit, GetPageCount, AddPage, UpdatePage, FinishPage, AddResource
void litePDF::TLitePDF::InsertPageFrom ( unsigned int  pageIndexTo,
litePDF::TLitePDF from,
unsigned int  pageIndexFrom 
)

Inserts an existing page at the given index from another PDF. Both objects should hold memory-based documents.

Parameters
pageIndexToPage index where to add the page; counts from 0. Adds page at the end, if out of bounds.
froma LitePDF object, from which add the page.
pageIndexFromPage index which to add from from; counts from 0.
Note
The two objects cannot be the same.
See Also
GetPageCount, AddPagesFrom, PageToResource
void litePDF::TLitePDF::LoadFromData ( const BYTE *  data,
unsigned int  dataLength,
const char *  password,
bool  forUpdate = false 
)

Makes the LitePDF object hold a memory-based PDF, which is loaded with a PDF data. This should be closed with Close. The forUpdate parameter specifies whether the file is being opened for incremental update. In that case saving such document will result in the changes being appended to the end of the original document, instead of resaving whole document.

Parameters
dataPDF data to load.
dataLengthLength of PDF data.
passwordPassword to use for encrypted documents.
forUpdateSet to true to open the file for incremental update, or set to false otherwise. Default is false.
See Also
CreateMemDocument, SaveToFile, SaveToData
void litePDF::TLitePDF::LoadFromFile ( const char *  fileName,
const char *  password,
bool  loadCompletely,
bool  forUpdate = false 
)

Makes the LitePDF object hold a memory-based PDF, which is loaded from a disk file. This should be closed with Close. The loadCompletely parameter is used to determine whether the file should be loaded into memory completely, or when the file can be read on demand. Using complete load requires more memory, but the disk file can be changed freely in the background, while incomplete load requires left the file without changes while being opened. The forUpdate parameter specifies whether the file is being opened for incremental update. In that case saving such document will result in the changes being appended to the end of the original document, instead of resaving whole document.

Parameters
fileNameFile name to load the PDF from.
passwordPassword to use for encrypted documents.
loadCompletelySet to true when the file should be loaded completely into memory, or false to keep the disk file in use while working with it.
forUpdateSet to true to open the file for incremental update, or set to false otherwise. Default is false.
See Also
LoadFromFileW
void litePDF::TLitePDF::LoadFromFileW ( const wchar_t *  fileName,
const char *  password,
bool  loadCompletely,
bool  forUpdate = false 
)

This is the same as LoadFromFile, the only difference is that the fileName is a wide string.

double litePDF::TLitePDF::MMToUnit ( double  mmValue)

Converts a value from millimeters to current unit. The caller does the rounding as needed.

Parameters
mmValueA value in millimeters to convert to the current unit.
Returns
The mmValue converted to the current unit.
See Also
GetUnit, UnitToMM, InchToUnit, UnitToInch, MMToUnitEx
double litePDF::TLitePDF::MMToUnitEx ( TLitePDFUnit  useUnit,
double  mmValue 
) const

Converts a value from millimeters to useUnit. The caller does the rounding as needed.

Parameters
useUnitThe TLitePDFUnit unit to convert the value to.
mmValueThe value in millimeters to convert.
Returns
The mmValue converted to useUnit unit.
See Also
UnitToMMEx, InchToUnitEx, UnitToInchEx, MMToUnit
unsigned int litePDF::TLitePDF::PageToResource ( unsigned int  pageIndex)

Creates a resource, which will reference an existing page. The page itself is not deleted after call of this.

Parameters
pageIndexPage index for which create the resource reference; counts from 0.
Returns
Resource identifier, or 0 on error.
See Also
GetPageCount, AddPagesFrom, AddPageFromAsResource, GetResourceSize, DrawResource
void litePDF::TLitePDF::PrepareEncryption ( const char *  userPassword,
const char *  ownerPassword,
unsigned int  permissions,
unsigned int  algorithm 
)

Prepares encryption for newly created documents. The LitePDF object should be empty. The encryption is used only with CreateFileDocument and CreateMemDocument, other functions ignore it. Use NULL or an empty ownerPassword to unset any previously set encryption properties. Loading an encrypted document lefts it encrypted on save too.

Parameters
userPasswordUser's password, can be an empty string, or NULL, then the user doesn't need to write any password.
ownerPasswordOwner's password. Can be NULL or an empty string, to unset encryption properties.
permissionsBit-or of TLitePDFEncryptPermission flags, to set user's permissions for the document.
algorithmOne of TLitePDFEncryptAlgorithm constants, an algorithm to be used to encrypt the document.
See Also
CreateFileDocument, CreateMemDocument
bool litePDF::TLitePDF::SaveToData ( BYTE *  data,
unsigned int *  dataLength 
)

Saves memory-based PDF into a data. The object should hold PDF created only with CreateMemDocument, LoadFromFile or LoadFromData. Using any other object results in an error.

In case the PDF document had been loaded with LoadFromFile, LoadFromFileW or LoadFromData with its 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.

Parameters
data[out] Actual data to store the PDF content to. It can be NULL, in which case the dataLength is populated with large-enough value to hold the whole data.
dataLength[in/out] Tells how many bytes can be stored in data. If data is NULL, then it is set to large-enough value. Passing non-NULL data with no enough large buffer results in a failure with no change on dataLength.
Returns
Whether succeeded.
Note
The only valid operation after this is either call of SaveToData again, to get information about necessary buffer size or data itself, close the document with Close, or free the TLitePDF object.
See Also
SaveToFile, SaveToDataWithSign, Close
bool litePDF::TLitePDF::SaveToDataWithSign ( unsigned int  signatureIndex,
BYTE *  data,
unsigned int *  dataLength 
)

Digitally signs a PDF document opened at the LitePDF object. The caller is responsible to set at least one signer with either AddSignerPFX or AddSignerPEM first. An alternative SaveToDataWithSignManual is provided when it's required to compute the signature hash manually by the caller.

In case the document had been loaded with LoadFromFile, LoadFromFileW or LoadFromData with its 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.

Parameters
signatureIndexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
data[out] Actual data to store the PDF content to. It can be NULL, in which case the dataLength is populated with large-enough value to hold the whole data.
dataLength[in/out] Tells how many bytes can be stored in data. If data is NULL, then it is set to large-enough value. Passing non-NULL data with no enough large buffer results in a failure with no change on dataLength.
Returns
Whether succeeded.
Note
The only valid operation after this is either call of SaveToDataWithSign again, to get information about necessary buffer size or data itself, close the document with Close, or free the TLitePDF object.
Signing already signed document can cause breakage of previous signatures, thus check whether the loaded document is already signed with GetDocumentIsSigned. Load the document with its forUpdate parameter set to true, to sign an existing document.
See Also
SaveToFileWithSign
bool litePDF::TLitePDF::SaveToDataWithSignManual ( unsigned int  signatureIndex,
TLitePDFAppendSignatureDataFunc  appendSignatureData,
void *  append_user_data,
TLitePDFFinishSignatureFunc  finishSignature,
void *  finish_user_data,
BYTE *  data,
unsigned int *  dataLength 
)

Digitally signs a PDF document opened at the LitePDF object. The caller is responsible for a detached hash computations and related certificate management.

In case the document had been loaded with LoadFromFile, LoadFromFileW or LoadFromData with its 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.

Parameters
signatureIndexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
appendSignatureDataCalled when more data should be added to hash computation. The function cannot be NULL, even when called the second time, to get actual data.
append_user_dataUser data value for the appendSignatureData callback.
finishSignatureCalled when all the data are processed, and the signature value is required. The signature_len contains size of the signature buffer. The callback is responsible to populate signature and signature_len with correct values. Set 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.
finish_user_dataUser data value for the finishSignature callback.
data[out] Actual data to store the PDF content to. It can be NULL, in which case the dataLength is populated with large-enough value to hold the whole data.
dataLength[in/out] Tells how many bytes can be stored in data. If data is NULL, then it is set to large-enough value. Passing non-NULL data with no enough large buffer results in a failure with no change on dataLength.
Returns
Whether succeeded.
Note
The only valid operation after this is either call of SaveToDataWithSignManual again, to get information about necessary buffer size or data itself, close the document with Close, or free the TLitePDF object.
Signing already signed document can cause breakage of previous signatures, thus check whether the loaded document is already signed with GetDocumentIsSigned. Load the document with its forUpdate parameter set to true, to sign an existing document.
See Also
SaveToFileWithSignManual, SaveToFileWithSign
void litePDF::TLitePDF::SaveToFile ( const char *  fileName)

Saves memory-based PDF into a file. The object should hold PDF created only with CreateMemDocument, LoadFromFile or LoadFromData. Using any other object results in an error.

In case the PDF document had been loaded with LoadFromFile, LoadFromFileW or LoadFromData with its 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.

Parameters
fileNameFile name to which save the memory-based PDF.
Note
The only valid operation after this is either close the document with Close, or free the TLitePDF object.
See Also
SaveToFileW, SaveToData, SaveToFileWithSign, Close
void litePDF::TLitePDF::SaveToFileW ( const wchar_t *  fileName)

This is the same as SaveToFile, the only difference is that the fileName is a wide string.

void litePDF::TLitePDF::SaveToFileWithSign ( const char *  fileName,
unsigned int  signatureIndex 
)

Digitally signs a PDF document opened at the LitePDF object. The caller is responsible to set at least one signer with either AddSignerPFX or AddSignerPEM first. An alternative SaveToFileWithSignManual is provided when it's required to compute the signature hash manually by the caller.

In case the document had been loaded with LoadFromFile, LoadFromFileW or LoadFromData with its 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.

Parameters
fileNameA file name where to save signed PDF document.
signatureIndexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
Note
The only valid operation after this is either close the document with Close, or free the TLitePDF object.
Signing already signed document can cause breakage of previous signatures, thus check whether the loaded document is already signed with GetDocumentIsSigned. Load the document with its forUpdate parameter set to true, to sign an existing document.
See Also
SaveToFileWithSignW, SaveToDataWithSign
void litePDF::TLitePDF::SaveToFileWithSignManual ( const char *  fileName,
unsigned int  signatureIndex,
TLitePDFAppendSignatureDataFunc  appendSignatureData,
void *  append_user_data,
TLitePDFFinishSignatureFunc  finishSignature,
void *  finish_user_data 
)

Digitally signs a PDF document opened at the LitePDF object. The caller is responsible for a detached hash computations and related certificate management.

In case the document had been loaded with LoadFromFile, LoadFromFileW or LoadFromData with its 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.

Parameters
fileNameA file name where to save signed PDF document.
signatureIndexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
appendSignatureDataCalled when more data should be added to hash computation. The function cannot be NULL, even when called the second time, to get actual data.
append_user_dataUser data value for the appendSignatureData callback.
finishSignatureCalled when all the data are processed, and the signature value is required. The signature_len contains size of the signature buffer. The callback is responsible to populate signature and signature_len with correct values. Set 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.
finish_user_dataUser data value for the finishSignature callback.
Note
The only valid operation after this is either close the document with Close, or free the TLitePDF object.
Signing already signed document can cause breakage of previous signatures, thus check whether the loaded document is already signed with GetDocumentIsSigned. Load the document with its forUpdate parameter set to true, to sign an existing document.
See Also
SaveToFileWithSign, SaveToFileWithSignManualW, SaveToDataWithSignManual
void litePDF::TLitePDF::SaveToFileWithSignManualW ( const wchar_t *  fileName,
unsigned int  signatureIndex,
TLitePDFAppendSignatureDataFunc  appendSignatureData,
void *  append_user_data,
TLitePDFFinishSignatureFunc  finishSignature,
void *  finish_user_data 
)

This is the same as SaveToFileWithSignManual, the only difference is that the fileName is a wide string.

void litePDF::TLitePDF::SaveToFileWithSignW ( const wchar_t *  fileName,
unsigned int  signatureIndex 
)

This is the same as SaveToFileWithSign, the only difference is that the fileName is a wide string.

void litePDF::TLitePDF::SetDocumentInfo ( const char *  name,
const wchar_t *  value 
)

Sets information about the document. The name can be one of the LitePDFDocumentInfo predefined constants.

Parameters
nameDocument info property name to set.
valueNull-terminated Unicode value to set.
void litePDF::TLitePDF::SetEvalFontFlagCallback ( TLitePDFEvalFontFlagCB  callback,
void *  userData 
)

Sets a callback to evaluate what to do with a font. The callback can be NULL, to unset any previously set value. See TLitePDFEvalFontFlagCB for more information about the callback parameters and what it can do.

Parameters
callbackA TLitePDFEvalFontFlagCB callback to set, or NULL.
userDataA user data to pass to callback when called.
void litePDF::TLitePDF::setOnError ( MLitePDFErrorEvent  pOnError,
void *  pOnErrorUserData 
)

Sets a custom callback for errors notified by the litePDF library. It's not necessary to be set. The errors are those returned during any function calls, but also during drawing, for example when some draw operation is not supported. Most of the object calls usually throw a TLitePDFException on errors.

Parameters
pOnErrorA callback to call.
pOnErrorUserDatauser data for the callback.
See Also
getLastErrorCode, getLastErrorMessage
void litePDF::TLitePDF::SetPageRotation ( unsigned int  pageIndex,
int  degrees 
)

Sets rotation of an existing page, in degrees. Expected values are 0, 90, 180 and 270.

Parameters
pageIndexPage index for which get the page size; counts from 0.
degreesRotation of the page to set, in degrees.
See Also
GetPageRotation
void litePDF::TLitePDF::SetSignatureAppearance ( unsigned int  index,
TLitePDFAppearance  appearanceType,
unsigned int  resourceID,
int  offsetX_u,
int  offsetY_u 
)

Sets the signature appearance.

Parameters
indexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
appearanceTypeOne of the LitePDFAppearance_Normal, LitePDFAppearance_Rollover and LitePDFAppearance_Down constants. At least the LitePDFAppearance_Normal type should be set, if the appearance of the signature is requested.
resourceIDAn existing resource ID of the annotation content, as shown to the user.
offsetX_uX-offset of the resource inside the annotation of the signature, in the current unit.
offsetY_uY-offset of the resource inside the annotation of the signature, in the current unit.
Note
The resource position offset is from [left, top] corner of the annotation rectangle.
See Also
GetUnit, AddResource, GetSignatureCount, CreateSignature
void litePDF::TLitePDF::SetSignatureCertification ( unsigned int  index,
TLitePDFCertificationPermission  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.

Parameters
indexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
permissionOne of the LitePDFCertificationPermission_NoPerms, LitePDFCertificationPermission_FormFill and LitePDFCertificationPermission_Annotations constants.
See Also
CreateSignature
void litePDF::TLitePDF::SetSignatureCreator ( unsigned int  index,
const char *  creator 
)

Sets signature creator. This can be left unset.

Parameters
indexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
creatorThe value to set.
See Also
GetSignatureCreator, GetSignatureCount
void litePDF::TLitePDF::SetSignatureDate ( unsigned int  index,
__int64  dateOfSign 
)

Sets signature field date of sign.

Parameters
indexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
dateOfSignDate 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.
See Also
GetSignatureDate, GetSignatureCount
void litePDF::TLitePDF::SetSignatureHash ( TLitePDFSignatureHash  signatureHash)

Sets the signature hash algorithm to be used. The default value is LitePDFSignatureHash_SHA512. It is used only when the SaveToFileWithSign or SaveToDataWithSign are used. The supported values are LitePDFSignatureHash_SHA1, LitePDFSignatureHash_SHA256, LitePDFSignatureHash_SHA384 and LitePDFSignatureHash_SHA512.

This value is remembered in general, not for any signature in particular.

Parameters
signatureHashThe hash algorithm to use.
See Also
SetSignatureSize, SaveToFileWithSignManual, SaveToFileWithSignManualW, SaveToDataWithSignManual
void litePDF::TLitePDF::SetSignatureLocation ( unsigned int  index,
const wchar_t *  location 
)

Sets signature location, aka where the signature had been made. This can be left unset.

Parameters
indexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
locationThe value to set.
See Also
GetSignatureLocation, GetSignatureCount
void litePDF::TLitePDF::SetSignatureReason ( unsigned int  index,
const wchar_t *  reason 
)

Sets signature reason.

Parameters
indexWhich signature to use; counts from 0. This might be less than GetSignatureCount.
reasonThe value to set.
See Also
GetSignatureReason, GetSignatureCount
void litePDF::TLitePDF::SetSignatureSize ( unsigned int  requestBytes)

Sets how many bytes the signature may require. The default value is 4096 bytes and it is automatically adjusted when the SaveToFileWithSign or 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.

Parameters
requestBytesHow many bytes the signature will require.
See Also
SaveToFileWithSignManual, SaveToFileWithSignManualW, SaveToDataWithSignManual
void litePDF::TLitePDF::SetUnit ( TLitePDFUnit  unitValue)

Sets a unit to use in functions which expect non-pixel size and position values. It can be one of TLitePDFUnit values. The default is LitePDFUnit_mm.

Parameters
unitValueOne of TLitePDFUnit values, to set as a unit.
See Also
Units, GetUnit, MMToUnit, UnitToMM, InchToUnit, UnitToInch
double litePDF::TLitePDF::UnitToInch ( double  unitValue)

Converts a value from the current unit to inches. The caller does the rounding as needed.

Parameters
unitValueA value in the current unit to convert to inches.
Returns
The unitValue converted to inches.
See Also
GetUnit, InchToUnit, MMToUnit, UnitToMM, UnitToInchEx
double litePDF::TLitePDF::UnitToInchEx ( TLitePDFUnit  useUnit,
double  unitValue 
) const

Converts a value from useUnit to inches. The caller does the rounding as needed.

Parameters
useUnitThe TLitePDFUnit unit to convert the value from.
unitValueThe value in useUnit to convert.
Returns
The unitValue in useUnit converted to inches.
See Also
InchToUnitEx, MMToUnitEx, UnitToMMEx, UnitToInch
double litePDF::TLitePDF::UnitToMM ( double  unitValue)

Converts a value from the current unit to millimeters. The caller does the rounding as needed.

Parameters
unitValueA value in the current unit to convert to millimeters.
Returns
The unitValue converted to millimeters.
See Also
GetUnit, MMToUnit, InchToUnit, UnitToInch, UnitToMMEx
double litePDF::TLitePDF::UnitToMMEx ( TLitePDFUnit  useUnit,
double  unitValue 
) const

Converts a value from useUnit to millimeters. The caller does the rounding as needed.

Parameters
useUnitThe TLitePDFUnit unit to convert the value from.
unitValueThe value in useUnit to convert.
Returns
The unitValue in useUnit converted to millimeters.
See Also
MMToUnitEx, InchToUnitEx, UnitToInchEx, UnitToMM
HDC litePDF::TLitePDF::UpdatePage ( unsigned int  pageIndex,
unsigned int  width_px,
unsigned int  height_px,
unsigned int  drawFlags 
)

Begins drawing into an already existing page. The page size in the current unit can be found by GetPageSize. The function fails, and returns NULL, if the pageIndex is out of bounds.

Parameters
pageIndexPage index which to update; counts from 0.
width_pxWidth of the new page in pixels.
height_pxHeight of the new page in pixels.
drawFlagsFlags for drawing functions. This is a bit-or of TLitePDFDrawFlags values and influences only AddPage, InsertPage, UpdatePage and AddResource functions.
Returns
Device context into which can be drawn with standard GDI functions. Finish the drawing, and the page update, with FinishPage.
See Also
GetPageCount, AddPage, InsertPage, FinishPage, AddResource

The documentation for this class was generated from the following file: