RTPDF-32
PDF Generator Library for RTOS-32
Typedefs
RTPDF-32.h File Reference
#include "RTPDF-DDI.h"

Go to the source code of this file.

Typedefs

typedef void * LPPDFINFO
 
typedef void * HANDLE
 

Functions

Library Initialization

Initialize the library, set license key, allocate and free internal structures

//
// This sample shows how to initialize and terminate the RTPDF-32 library
//
int main()
{
LPPDFINFO pdev = RTPdfInit();
if (pdev)
{
// provide a valid license key depending on the version of the library and licensed features
const char *szLicenseKey = "07EFCDAB...EA8B";
RTPdfSetLicenseKey(pdev, "*****", szLicenseKey, strlen(szLicenseKey));
// Add here code to render to PDF
// ...
// free all internal structures and terminate
RTPdfEnd(pdev);
}
}
void * LPPDFINFO
Definition: RTPDF-32.h:21
void RTPdfEnd(LPPDFINFO pdev)
Clear all memory allocated while creating a PDF file and free the PDFINFO structure.
LPPDFINFO RTPdfInit()
Allocate memory and initialize a PDFINFO structure.
int RTPdfSetLicenseKey(LPPDFINFO pdev, const char *szLicensee, const char *szKey, int nKeyLen)
Set the License Key for the library. The license key contains specific licensed features and the libr...
LPPDFINFO RTPdfInit ()
 Allocate memory and initialize a PDFINFO structure. More...
 
void RTPdfEnd (LPPDFINFO pdev)
 Clear all memory allocated while creating a PDF file and free the PDFINFO structure. More...
 
int RTPdfSetLicenseKey (LPPDFINFO pdev, const char *szLicensee, const char *szKey, int nKeyLen)
 Set the License Key for the library. The license key contains specific licensed features and the library version number Should be called directly after RTPdfInit. More...
 
Document and Page Processing Functions

Start and End a PDF document, Start and End document pages

//
// This sample shows how to start a new PDF document and create a couple of pages
//
int main()
{
LPPDFINFO pdev = RTPdfInit();
if (pdev)
{
// provide a valid license key depending on the version of the library and licensed features
const char *szLicenseKey = "07EFCDAB...EA8B";
RTPdfSetLicenseKey(pdev, "*****", szLicenseKey, strlen(szLicenseKey));
// start a new PDF document
// start page 1
// Add here code to render page 1
// ...
// end page 1
RTPdfEndPage(pdev);
// start page 2
// Add here code to render page 2
// ...
// end page 2
RTPdfEndPage(pdev);
// signal end of document
RTPdfEndDoc(pdev);
// free all internal structures and terminate
RTPdfEnd(pdev);
}
}
int RTPdfStartDoc(LPPDFINFO pdev)
Start a new PDF document.
int RTPdfStartPage(LPPDFINFO pdev)
Start a new page, should be called after a call to RTPdfStartDoc and before a new page is started.
int RTPdfEndDoc(LPPDFINFO pdev)
End the current document, no output is allowed after this call.
int RTPdfEndPage(LPPDFINFO pdev)
End the current page.
int RTPdfStartDoc (LPPDFINFO pdev)
 Start a new PDF document. More...
 
int RTPdfStartPage (LPPDFINFO pdev)
 Start a new page, should be called after a call to RTPdfStartDoc and before a new page is started. More...
 
int RTPdfEndPage (LPPDFINFO pdev)
 End the current page. More...
 
int RTPdfEndDoc (LPPDFINFO pdev)
 End the current document, no output is allowed after this call. More...
 
int RTPdfResetDevmode (LPPDFINFO pdev, PDEVMODEA pdm)
 Set the page dimensions and orientation of all pages following this call. More...
 
void RTPdfSetDrawingOrigin (LPPDFINFO pdev, long lXOrg, long lYOrg)
 Shift all drawing operations by a certain distance To reset the origin, call the same function with opposite X and Y values. More...
 
Callback Functions

These are callback functions from the library. The caller has to implement these functions in order to tell the library where to store the PDF data The callback IsMetricCountry also configures the library for Letter or A4 papersize

//
// This sample shows how to write the PDF file to a file under the c:\temp folder
//
HANDLE RTPdfOpenPort(const char *szDocTitle, const unsigned long dwJobId)
{
return (HANDLE)CreateFile("c:\\temp\\test.pdf", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
}
int RTPdfWritePort(HANDLE hPort, const unsigned char* pData, unsigned long *pdwDataSize)
{
return WriteFile(hPort, pData, *pdwDataSize, pdwDataSize, NULL);
}
int RTPdfClosePort(HANDLE hPort, int bCancel)
{
return CloseHandle(hPort);
}
int RTPdfClosePort(HANDLE hPort, int bCancel)
Close the file or port that was opened in RTPdfOpenPort.
int RTPdfWritePort(HANDLE hPort, const unsigned char *pData, unsigned long *pdwDataSize)
Write a block of data to the specified file or port.
void * HANDLE
Definition: RTPDF-32.h:22
HANDLE RTPdfOpenPort(const char *szDocTitle, const unsigned long dwJobId)
Allows the caller to create a file or open a port to where the PDF data is sent.
HANDLE RTPdfOpenPort (const char *szDocTitle, const unsigned long dwJobId)
 Allows the caller to create a file or open a port to where the PDF data is sent. More...
 
int RTPdfWritePort (HANDLE hPort, const unsigned char *pData, unsigned long *pdwDataSize)
 Write a block of data to the specified file or port. More...
 
int RTPdfClosePort (HANDLE hPort, int bCancel)
 Close the file or port that was opened in RTPdfOpenPort. More...
 
int IsMetricCountry ()
 This function is used to set the default paper size to Letter or A4 By default RTPDF-32 attempts to read the paper size from the system Locale settings and will only call IsMetricCountry if this is not successful. More...
 
Text Rendering Functions

Font and Text handling functions

//
// This sample shows how to select a font and render some text on a page
//
// document must be started before creating any fonts
// Load Helvetica (Arial) font
HANDLE hFnt1 = RTPdfGetFont(pdev, "Helvetica", 0, 0, 0, 1, 0);
// start page
// set font and text size
RTPdfSetFont(pdev, hFnt1, 10.4f);
// output some text
RTPdfTextOut(pdev, NULL, NULL, FLOAT2LONG(100.0f), FLOAT2LONG(100.0f), 0.0f, (const BYTE *)"RTPDF Text Output", strlen("RTPDF Text Output"), 0);
RTPdfEndPage(pdev);
int RTPdfSetFont(LPPDFINFO pdev, HANDLE hFont, float fPointSize)
Set the font to be used in all text drawing operations after this function is called.
HANDLE RTPdfGetFont(LPPDFINFO pdev, const char *szFontName, int bBold, int bItalic, int nCodePage, int bType1, int bCID)
Create a PDF font object and return a handle that can be used to render text on a page RTPdfStartDoc ...
int RTPdfTextOut(LPPDFINFO pdev, CLIPOBJ *pco, BRUSHOBJ *pboText, long lPosX, long lPosY, float fAngle, const BYTE *pbCharCodes, int nCharCount, int nEncoding)
HANDLE RTPdfGetFont (LPPDFINFO pdev, const char *szFontName, int bBold, int bItalic, int nCodePage, int bType1, int bCID)
 Create a PDF font object and return a handle that can be used to render text on a page RTPdfStartDoc has to be called before any fonts are created The PDF specifications define a set of 14 fonts that can be used within a PDF document without prior definition of these fonts Because RTOS-32 has no support for fonts, only these 14 predefined fonts are upported by RTPDF-32 These fonts are: Helvetica (equivalent to Arial), Helvetica-Bold, Helvetica-BoldItalic, Helvetica-Italic Times (equivalent to Times New Roman), Times-Bold, Times-BoldItalic, Times-Italic Courier (equivalent to Courier New), Courier-Bold, Courier-BoldItalic, Courier-Italic Symbol ITC Zapf Dingbats. More...
 
int RTPdfSetFont (LPPDFINFO pdev, HANDLE hFont, float fPointSize)
 Set the font to be used in all text drawing operations after this function is called. More...
 
int RTPdfSetTextSpacing (LPPDFINFO pdev, long lWordSpacing, long lCharSpacing)
 Set the Word and Character spacing of any text drawn after this function is called. More...
 
int RTPdfTextOut (LPPDFINFO pdev, CLIPOBJ *pco, BRUSHOBJ *pboText, long lPosX, long lPosY, float fAngle, const BYTE *pbCharCodes, int nCharCount, int nEncoding)
 
float RTPdfGetTextWidth (HANDLE hFont, float fPointSize, const BYTE *pbCharCodes, int nCharCount, int nEncoding)
 Get width of a text string given the font name and size. More...
 
int RTPdfDrawText (LPPDFINFO pdev, RECT rcText, UINT nTextAlign, int bClipToBoundaries, COLORREF crTextColor, const BYTE *pbCharCodes, int nCharCount, int nEncoding)
 Draw text given a bounding rectangle. More...
 
Image Rendering Functions

//
// This sample shows how to render an image
//
// load an image from memory into the PDF object
HANDLE hImg1 = RTPdfGetImage(pdev, Test_Image_Jpeg, sizeof(Test_Image_Jpeg));
// create a clipping path to crop the image
CLIPOBJ clipPath = {
0, // Region Identifier, should be 0
{ FLOAT2LONG(36.0f), FLOAT2LONG(36.0f), FLOAT2LONG(80.0f), FLOAT2LONG(80.0f) }, // Rectangular region bounds
DC_RECT, // Rectangular clipping region, the only supported value
FC_RECT, // Complexity of the region
0, // Not used
0 // Not used
};
// draw image
RTPdfDrawImage(pdev, &clipPath, hImg1, FLOAT2LONG(36.0f), FLOAT2LONG(36.0f), FLOAT2LONG(72.5f), FLOAT2LONG(0.0f));
HANDLE RTPdfGetImage(LPPDFINFO pdev, const BYTE *pbImageData, unsigned long ulImageSize)
Output an image object to the PDF stream without yet drawing any image BMP, JPeg and PNG images are c...
int RTPdfDrawImage(LPPDFINFO pdev, CLIPOBJ *pco, HANDLE hImage, long lStartX, long lStartY, long lWidth, long lHeight, int bKeepAspectRatio)
Draw a preloaded image to a specific location on a page All units should be provided in PDF units whe...
HANDLE RTPdfGetImage (LPPDFINFO pdev, const BYTE *pbImageData, unsigned long ulImageSize)
 Output an image object to the PDF stream without yet drawing any image BMP, JPeg and PNG images are currently supported. This call will fail if a specific image is not supported by the PDF specifications or by RTPDF-32 Example: PNG images with a bit depth different than 8 are not supported The returned handle can later be used to draw the image on one or multiple pages The RTPDF-32 library deletes the returned handle when the document is closed. More...
 
int RTPdfDrawImage (LPPDFINFO pdev, CLIPOBJ *pco, HANDLE hImage, long lStartX, long lStartY, long lWidth, long lHeight, int bKeepAspectRatio)
 Draw a preloaded image to a specific location on a page All units should be provided in PDF units where 1 unit is 1/72 of an inch If the destination height of the image is specified as 0.0f, the width of the image is adjusted to keep the original aspect ratio If the destination width of the image is specified as 0.0f, the height of the image is adjusted to keep the original aspect ratio If both width and height are specified and bKeepAspectRatio is 1, the image is centered in the rectangle while keeping its aspect ratio. More...
 

Vector Rendering Functions

//
// This sample shows how to draw a polygon with dashed lines and fill it with a solid color
//
// create a path object to draw
PATHOBJ *ppo = RTPdfCreatePath(pdev);
// start coordinates of our polygon
POINTFIX pfx1 = { FLOAT2FIX(100.4f), FLOAT2FIX(100.0f) };
// add 2 other vertices
POINTFIX pfx2[] = { { FLOAT2FIX(200.6f), FLOAT2FIX(200.0f) },
{ FLOAT2FIX(300.6f), FLOAT2FIX(200.0f) }
};
// define the stroked and fill brushes
BRUSHOBJ stroke_brush = { RGB2GDIBRUSH(0x00, 0x55, 0xAF), 0, 0 }; // blue-ish
BRUSHOBJ fill_brush = { RGB2GDIBRUSH(0x00, 0xAF, 0x55), 0, 0 }; // green-ish
// create a dashed line with a proportion of 5 to 1
FLOAT_LONG DashedLineStyle[2];
DashedLineStyle[0].l = 10;
DashedLineStyle[1].l = 2;
LINEATTRS DashedLine = {
0, // Option flags, should be 0
JOIN_ROUND, // Join style
ENDCAP_ROUND, // End cap style
0, // Line width
0, // Not used
_countof(DashedLineStyle), // Number of entries in the style array
DashedLineStyle, // Style array for non-continuous lines
0 // Not used
};
DashedLine.elWidth.l = 10; // line width in pixels x 10
PATHOBJ_bMoveTo(ppo, pfx1);
PATHOBJ_bPolyLineTo(ppo, pfx2, _countof(pfx2));
// close our figure
PATHOBJ_bPolyLineTo(ppo, &pfx1, 1);
RTPdfStrokeAndFillPath(pdev, ppo, NULL, &stroke_brush, &DashedLine, &fill_brush, NULL, 0, PDF_PATH_FILLANDSTROKE);
// always delete the path object when done
PATHOBJ * RTPdfCreatePath(LPPDFINFO pdev)
Create a path object made of lines and curves to be used in all vector drawing operations See PATHOB...
#define PDF_PATH_FILLANDSTROKE
Definition: RTPDF-32.h:658
void RTPdfDeletePath(PATHOBJ *ppo)
Delete the path object created through RTPdfCreatePath.
int RTPdfStrokeAndFillPath(LPPDFINFO pdev, PATHOBJ *ppo, CLIPOBJ *pco, BRUSHOBJ *pboStroke, PLINEATTRS plineattrs, BRUSHOBJ *pboFill, PPOINTL pptlBrushOrg, ULONG mix, FLONG flOptions)
Draw a path object made of straight lines and/or Bezier curves If requested, also fill the path using...
#define PDF_PATH_NONE   0
 
#define PDF_PATH_STROKE   1
 
#define PDF_PATH_FILL   2
 
#define PDF_PATH_FILLANDSTROKE   3
 
#define PDF_PATH_FILL_WINDING   8
 
PATHOBJ * RTPdfCreatePath (LPPDFINFO pdev)
 Create a path object made of lines and curves to be used in all vector drawing operations
See PATHOBJ_bMoveTo, PATHOBJ_bPolyLineTo and PATHOBJ_bPolyBezierTo for how to add elements to the path. More...
 
void RTPdfDeletePath (PATHOBJ *ppo)
 Delete the path object created through RTPdfCreatePath. More...
 
int RTPdfStrokeAndFillPath (LPPDFINFO pdev, PATHOBJ *ppo, CLIPOBJ *pco, BRUSHOBJ *pboStroke, PLINEATTRS plineattrs, BRUSHOBJ *pboFill, PPOINTL pptlBrushOrg, ULONG mix, FLONG flOptions)
 Draw a path object made of straight lines and/or Bezier curves If requested, also fill the path using the specified brush. More...
 

Document Metadata and Structure Functions

enum  _DocumentInfo {
  DocumentInfoTitle = 0 , DocumentInfoAuthor = 1 , DocumentInfoCreator = 2 , DocumentInfoSubject = 3 ,
  DocumentInfoKeywords = 4
}
 Enumeration of the various document info attributes that can be used in RTPdfSetDocumentInfo. More...
 
typedef enum _DocumentInfo DocumentInfo
 Enumeration of the various document info attributes that can be used in RTPdfSetDocumentInfo. More...
 
int RTPdfSetDocumentInfo (LPPDFINFO pdev, DocumentInfo nDocumentInfo, const BYTE *szEntryValue)
 Set a document information attribute (also known as Metadata)
The attributes should be set before calling RTPdfStartDoc and cannot be modified afterwards
Document attributes in PDF use the PDFDocEncoding character encoding which is documented in the PDF specs
Unicode strings can be set by prefixing the string with 0xFEFF. The macro INIT_UNICODE_STRING can be used to create unicode strings
. More...
 
int RTPdfSetLayer (LPPDFINFO pdev, PWSTR pwstrLayerTitle)
 Specify a PDF layer on which to place the next objects. More...
 
void RTPdfSetHyperLink (LPPDFINFO pdev, const PRECTL prclHyperLink, PWSTR pwszDestination)
 Create a hyperlink to an internal location (bookmark) or external location (URL) More...
 
int RTPdfSetBookmark (LPPDFINFO pdev, int nParent, PWSTR pwstrBookmarkTitle)
 Add a bookmark to the current location in the bookmarks tree. More...
 

Macro Definition Documentation

◆ PDF_PATH_FILL

#define PDF_PATH_FILL   2

◆ PDF_PATH_FILL_WINDING

#define PDF_PATH_FILL_WINDING   8

◆ PDF_PATH_FILLANDSTROKE

#define PDF_PATH_FILLANDSTROKE   3

◆ PDF_PATH_NONE

#define PDF_PATH_NONE   0

◆ PDF_PATH_STROKE

#define PDF_PATH_STROKE   1

Typedef Documentation

◆ DocumentInfo

Enumeration of the various document info attributes that can be used in RTPdfSetDocumentInfo.

◆ HANDLE

typedef void* HANDLE

◆ LPPDFINFO

typedef void* LPPDFINFO

Enumeration Type Documentation

◆ _DocumentInfo

Enumeration of the various document info attributes that can be used in RTPdfSetDocumentInfo.

Enumerator
DocumentInfoTitle 
DocumentInfoAuthor 
DocumentInfoCreator 
DocumentInfoSubject 
DocumentInfoKeywords 

Function Documentation

◆ IsMetricCountry()

int IsMetricCountry ( )

This function is used to set the default paper size to Letter or A4 By default RTPDF-32 attempts to read the paper size from the system Locale settings and will only call IsMetricCountry if this is not successful.

Returns
int 1 to set the default paper size to A4 or 0 for Letter

◆ RTPdfClosePort()

int RTPdfClosePort ( HANDLE  hPort,
int  bCancel 
)

Close the file or port that was opened in RTPdfOpenPort.

Parameters
hPortPointer to the file or port opened by the caller in RTPdfOpenPort
bCancel1 if the document was canceled, e.g. in the case of an error, 0 if the document terminated normally
Returns
int 1 if successful, 0 otherwise

◆ RTPdfCreatePath()

PATHOBJ * RTPdfCreatePath ( LPPDFINFO  pdev)

Create a path object made of lines and curves to be used in all vector drawing operations
See PATHOBJ_bMoveTo, PATHOBJ_bPolyLineTo and PATHOBJ_bPolyBezierTo for how to add elements to the path.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
Returns
PATHOBJ* Pointer to path object

◆ RTPdfDeletePath()

void RTPdfDeletePath ( PATHOBJ *  ppo)

Delete the path object created through RTPdfCreatePath.

Parameters
ppoPath object returned by RTPdfCreatePath
Returns
void

◆ RTPdfDrawImage()

int RTPdfDrawImage ( LPPDFINFO  pdev,
CLIPOBJ *  pco,
HANDLE  hImage,
long  lStartX,
long  lStartY,
long  lWidth,
long  lHeight,
int  bKeepAspectRatio 
)

Draw a preloaded image to a specific location on a page All units should be provided in PDF units where 1 unit is 1/72 of an inch If the destination height of the image is specified as 0.0f, the width of the image is adjusted to keep the original aspect ratio If the destination width of the image is specified as 0.0f, the height of the image is adjusted to keep the original aspect ratio If both width and height are specified and bKeepAspectRatio is 1, the image is centered in the rectangle while keeping its aspect ratio.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
pcoPointer to a clipping object used to clip the path
hImageHandle of an image returned by RTPdfGetImage
lStartXLeft coordinate
lStartYTop coordinate
lWidthDestination width of the image
lHeightDestination height of the image
bKeepAspectRatioFlag to center the image while keeping its aspect ratio
Returns
int 1 if successful, 0 otherwise

◆ RTPdfDrawText()

int RTPdfDrawText ( LPPDFINFO  pdev,
RECT  rcText,
UINT  nTextAlign,
int  bClipToBoundaries,
COLORREF  crTextColor,
const BYTE *  pbCharCodes,
int  nCharCount,
int  nEncoding 
)

Draw text given a bounding rectangle.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
rcTextBounding rectangle
nTextAlignCombination of horizontal and vertical text alignement. Should be created using MAKELONG(horzAlign, vertAlign) For values of horizontal and vertical alignment values check the acReportCell::HorzAlign and acReportCellVertAlign enumerators
bClipToBoundariesIf 1 clip the text to cell rcText boundaries
crTextColorColor in GDI format to render the text, can be created using the RGB2GDICOLOR macro
pbCharCodesText encoded in WinAnsi character codes
nCharCountNumber of characters in pbCharCodes
nEncodingReserved for future use
Returns
int 1 if successful, 0 otherwise

◆ RTPdfEnd()

void RTPdfEnd ( LPPDFINFO  pdev)

Clear all memory allocated while creating a PDF file and free the PDFINFO structure.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit

◆ RTPdfEndDoc()

int RTPdfEndDoc ( LPPDFINFO  pdev)

End the current document, no output is allowed after this call.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
Returns
int 1 if successful, 0 otherwise

◆ RTPdfEndPage()

int RTPdfEndPage ( LPPDFINFO  pdev)

End the current page.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
Returns
int 1 if successful, 0 otherwise

◆ RTPdfGetFont()

HANDLE RTPdfGetFont ( LPPDFINFO  pdev,
const char *  szFontName,
int  bBold,
int  bItalic,
int  nCodePage,
int  bType1,
int  bCID 
)

Create a PDF font object and return a handle that can be used to render text on a page RTPdfStartDoc has to be called before any fonts are created The PDF specifications define a set of 14 fonts that can be used within a PDF document without prior definition of these fonts Because RTOS-32 has no support for fonts, only these 14 predefined fonts are upported by RTPDF-32 These fonts are: Helvetica (equivalent to Arial), Helvetica-Bold, Helvetica-BoldItalic, Helvetica-Italic Times (equivalent to Times New Roman), Times-Bold, Times-BoldItalic, Times-Italic Courier (equivalent to Courier New), Courier-Bold, Courier-BoldItalic, Courier-Italic Symbol ITC Zapf Dingbats.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
szFontNameThe font name and style to be used
bBoldReserved for future use
bItalicReserved for future use
nCodePageReserved for future use
bType1Reserved for future use
bCIDReserved for future use
Returns
HANDLE to the font that can used in RTPdfSetFont, NULL of the function fails

◆ RTPdfGetImage()

HANDLE RTPdfGetImage ( LPPDFINFO  pdev,
const BYTE *  pbImageData,
unsigned long  ulImageSize 
)

Output an image object to the PDF stream without yet drawing any image BMP, JPeg and PNG images are currently supported. This call will fail if a specific image is not supported by the PDF specifications or by RTPDF-32 Example: PNG images with a bit depth different than 8 are not supported The returned handle can later be used to draw the image on one or multiple pages The RTPDF-32 library deletes the returned handle when the document is closed.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
pbImageDataPointer to the image data in Jpeg, PNG or BMP formats
ulImageSizeSize of the image data in pbImageData
Returns
HANDLE Pointer to the image object to be used in RTPdfDrawImage or NULL if the function fails

◆ RTPdfGetTextWidth()

float RTPdfGetTextWidth ( HANDLE  hFont,
float  fPointSize,
const BYTE *  pbCharCodes,
int  nCharCount,
int  nEncoding 
)

Get width of a text string given the font name and size.

Parameters
hFontPointer to the font returned in RTPdfGetFont
fPointSizeText size in Points
pbCharCodesText string
nCharCountNumber of characters in text string
nEncodingReserved for future use
Returns
float Width of text

◆ RTPdfInit()

LPPDFINFO RTPdfInit ( )

Allocate memory and initialize a PDFINFO structure.

Returns
LPPDFINFO Pointer to allocated PDFINFO structure

◆ RTPdfOpenPort()

HANDLE RTPdfOpenPort ( const char *  szDocTitle,
const unsigned long  dwJobId 
)

Allows the caller to create a file or open a port to where the PDF data is sent.

Parameters
szDocTitleOptional document title if set by RTPdfSetDocumentInfo
dwJobIdReserved for future use
Returns
HANDLE Pointer to the file or port opened by the caller

◆ RTPdfResetDevmode()

int RTPdfResetDevmode ( LPPDFINFO  pdev,
PDEVMODEA  pdm 
)

Set the page dimensions and orientation of all pages following this call.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
pdmPointer to a Windows Devmode structure containing the page information. The following settings are currently supported:
dmOrientation - dmPaperSize - dmPaperLength - dmPaperWidth - dmFormName
Returns
int 1 if successful, 0 otherwise
Sample Code
// change the format of subsequent pages to Legal and the orientation to Landscape
DEVMODEA dm;
memset(&dm, 0, sizeof(dm));
dm.dmSize = sizeof(dm);
lstrcpy((LPSTR)dm.dmFormName, "Legal");
dm.dmOrientation = DMORIENT_LANDSCAPE;
// specify which DEVMODE fields are being modified
dm.dmFields |= (DM_FORMNAME | DM_ORIENTATION);
RTPdfResetDevmode(pdev, &dm);
// start new page
int RTPdfResetDevmode(LPPDFINFO pdev, PDEVMODEA pdm)
Set the page dimensions and orientation of all pages following this call.

◆ RTPdfSetBookmark()

int RTPdfSetBookmark ( LPPDFINFO  pdev,
int  nParent,
PWSTR  pwstrBookmarkTitle 
)

Add a bookmark to the current location in the bookmarks tree.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
nParentParent ID of this bookmark. Set to 0 for the root bookmark or a value returned by a previous call to RTPdfSetBookmark
pwstrBookmarkTitleTitle of the bookmark in double-byte (Unicode) format
Returns
int a negative value if an error occurs. When successful, returns the level of the bookmark which can be used as a parent to a subsequent bookmark
Sample Code
// output first page
// set a bookmark to the first table on the first page
RTPdfSetBookmark(pdev, 0, L"Table on Page 1");
// run the table creation test
DrawTableTest(pdev);
// output second page
// set a bookmark to the first table on the second page
RTPdfSetBookmark(pdev, 0, L"Table on Page 2");
// run the table creation test
DrawTableTest(pdev);
int RTPdfSetBookmark(LPPDFINFO pdev, int nParent, PWSTR pwstrBookmarkTitle)
Add a bookmark to the current location in the bookmarks tree.

◆ RTPdfSetDocumentInfo()

int RTPdfSetDocumentInfo ( LPPDFINFO  pdev,
DocumentInfo  nDocumentInfo,
const BYTE *  szEntryValue 
)

Set a document information attribute (also known as Metadata)
The attributes should be set before calling RTPdfStartDoc and cannot be modified afterwards
Document attributes in PDF use the PDFDocEncoding character encoding which is documented in the PDF specs
Unicode strings can be set by prefixing the string with 0xFEFF. The macro INIT_UNICODE_STRING can be used to create unicode strings
.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
nDocumentInfoOne of the DocumentInfo attributes to set
szEntryValueValue of the attribute, either single-byte or douvle-byte
Returns
int 1 if successful, 0 otherwise
Sample Code
//
// set document info attributes in single-byte (PDFDocEncoding) or Unicode formats
//
UNICODE_STRING us;
INIT_UNICODE_STRING(us, "\x07\x68\x98\x98"); // simplified chinese for "Title"
RTPdfSetDocumentInfo(pdev, DocumentInfoAuthor, (LPBYTE)"Amyuni Technologies");
int RTPdfSetDocumentInfo(LPPDFINFO pdev, DocumentInfo nDocumentInfo, const BYTE *szEntryValue)
Set a document information attribute (also known as Metadata) The attributes should be set before ca...
@ DocumentInfoTitle
Definition: RTPDF-32.h:214
@ DocumentInfoAuthor
Definition: RTPDF-32.h:215

◆ RTPdfSetDrawingOrigin()

void RTPdfSetDrawingOrigin ( LPPDFINFO  pdev,
long  lXOrg,
long  lYOrg 
)

Shift all drawing operations by a certain distance To reset the origin, call the same function with opposite X and Y values.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
lXOrgShift along the X axis
lYOrgShift along the Y axis

◆ RTPdfSetFont()

int RTPdfSetFont ( LPPDFINFO  pdev,
HANDLE  hFont,
float  fPointSize 
)

Set the font to be used in all text drawing operations after this function is called.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
hFontPointer to the font returned in RTPdfGetFont
fPointSizeText size in Points
Returns
int 1 if successful, 0 otherwise

◆ RTPdfSetHyperLink()

void RTPdfSetHyperLink ( LPPDFINFO  pdev,
const PRECTL  prclHyperLink,
PWSTR  pwszDestination 
)

Create a hyperlink to an internal location (bookmark) or external location (URL)

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
prclHyperLinkPointer to a rectangle containing the bounds of the hyperlink. If this parameter is NULL, the location of the last drawn object is used
pwszDestinationIn double-byte (Unicode) format. Can be one of two things:
1) If pwszDestination starts with a number sign (#) the hyperlink points to an internal bookmark
2) If pwszDestination does not start with #, it should contain a valid external URL to which the hyperlink points
Sample Code
// set a hyperlink on cell [1,1] to different location on the document (Bookmark)
table.GetCellsBoundRect(3, 3, 3, 3, rc);
// the cell coordinates are relative to the table origin and have to be offset by the origin of the table
RECTL rcl = { rc.left + rcTable.left, rc.top + rcTable.top, rc.right + rcTable.left, rc.bottom + rcTable.top };
RTPdfSetHyperLink(pdev, &rcl, L"#Table on Page 1");
RTPdfDrawImage(pdev, NULL, hImg4, FLOAT2LONG(36.0f), FLOAT2LONG(320.0f), FLOAT2LONG(150.0f), FLOAT2LONG(0.0f), FALSE);
// set a hyperlink on the last image object to an external URL
RTPdfSetHyperLink(pdev, NULL, L"https://www.amyuni.com");
void RTPdfSetHyperLink(LPPDFINFO pdev, const PRECTL prclHyperLink, PWSTR pwszDestination)
Create a hyperlink to an internal location (bookmark) or external location (URL)

◆ RTPdfSetLayer()

int RTPdfSetLayer ( LPPDFINFO  pdev,
PWSTR  pwstrLayerTitle 
)

Specify a PDF layer on which to place the next objects.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
pwstrLayerTitleIn double-byte (Unicode) format. Can be one of three things:
1) If RTPdfSetLayer is called inside a page (between calls to StartPage and EndPage), pwstrLayerTitle is the title of the layer on which to place the objects
2) If RTPdfSetLayer is called outside a page, pwstrLayerTitle should contain the list and order in which to display the layer tree in a PDF viewer
3) If pwstrLayerTitle is an empty string, it closes the last opened layer and moves up one level
Note
The Order should be a string in the format "/Order[(Layer Title 1)(Layer Title 2)(...)]" for a single level tree of layers
Or "/Order[(Layer Title 1)[(Layer Subtitle 1)(Layer Subtitle 2)(...)] (Layer Title 2)[(Layer Subtitle 21)(Layer Subtitle 22)(...)]]" for a multi-level tree of layers
Returns
int a negative value if an error occurs. When successful, returns the level of the layer in a multi-level tree of layers, this allows to properly close all the layers
Sample Code
// set document information before starting the document
SetDocumentInfoTest(pdev);
RTPdfSetLayer(pdev, L"/Order[(Clipped Polygons)[(Clipped Polygons - 1)(Clipped Polygons - 2)](Some Text)]");
if (!RTPdfStartDoc(pdev))
{
...
}
// output first page
// place the next polygon in a PDF layer named "Clipped Polygons - 1" under "Clipped Polygons"
RTPdfSetLayer(pdev, L"Clipped Polygons");
RTPdfSetLayer(pdev, L"Clipped Polygons - 1");
// output some polygons
DrawPolygonTest(pdev);
// end previous layers
RTPdfSetLayer(pdev, L"");
RTPdfSetLayer(pdev, L"");
int RTPdfSetLayer(LPPDFINFO pdev, PWSTR pwstrLayerTitle)
Specify a PDF layer on which to place the next objects.

◆ RTPdfSetLicenseKey()

int RTPdfSetLicenseKey ( LPPDFINFO  pdev,
const char *  szLicensee,
const char *  szKey,
int  nKeyLen 
)

Set the License Key for the library. The license key contains specific licensed features and the library version number Should be called directly after RTPdfInit.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
szLicenseeName of licensee
szKeyLicense key provided by Amyuni
nKeyLenLength in bytes of the szKey
Returns
int 0 if successful, a negative error code otherwise

◆ RTPdfSetTextSpacing()

int RTPdfSetTextSpacing ( LPPDFINFO  pdev,
long  lWordSpacing,
long  lCharSpacing 
)

Set the Word and Character spacing of any text drawn after this function is called.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
lWordSpacingSpacing to be added to the space character (character code 32)
lCharSpacingSpacing to be added between characters
Returns
int 1 if successful, 0 otherwise

◆ RTPdfStartDoc()

int RTPdfStartDoc ( LPPDFINFO  pdev)

Start a new PDF document.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
Returns
int 1 if successful, 0 otherwise

◆ RTPdfStartPage()

int RTPdfStartPage ( LPPDFINFO  pdev)

Start a new page, should be called after a call to RTPdfStartDoc and before a new page is started.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
Returns
int 1 if successful, 0 otherwise

◆ RTPdfStrokeAndFillPath()

int RTPdfStrokeAndFillPath ( LPPDFINFO  pdev,
PATHOBJ *  ppo,
CLIPOBJ *  pco,
BRUSHOBJ *  pboStroke,
PLINEATTRS  plineattrs,
BRUSHOBJ *  pboFill,
PPOINTL  pptlBrushOrg,
ULONG  mix,
FLONG  flOptions 
)

Draw a path object made of straight lines and/or Bezier curves If requested, also fill the path using the specified brush.

Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
ppoPointer to a path object returned by RTPdfCreatePath
pcoPointer to a clipping object used to clip the path to a rectangular area
pboStrokeBrush object used to draw the outline of the path
plineattrsLine attributes that define things such as width of the line, line ending style and so on
pboFillBrush object used to fill the path
pptlBrushOrgReserved for future use
mixReserved for future use
flOptionsA combination of PDF_PATH options as defined above
Returns
int 1 if successful, 0 otherwise

◆ RTPdfTextOut()

int RTPdfTextOut ( LPPDFINFO  pdev,
CLIPOBJ *  pco,
BRUSHOBJ *  pboText,
long  lPosX,
long  lPosY,
float  fAngle,
const BYTE *  pbCharCodes,
int  nCharCount,
int  nEncoding 
)
Parameters
pdevPointer to PDFINFO structure returned by RTPdfInit
pcoPointer to a clipping object used to clip the path to a rectangular area
pboTextPointer to Brush object with which to paint the text
lPosXHorizontal position in PDF units
lPosYVertical position in PDF units
fAngleRotation angle of text in degrees and measured counter-clockwise
pbCharCodesText encoded in WinAnsi character codes
nCharCountNumber of characters in pbCharCodes
nEncodingReserved for future use
Returns
int 1 if successful, 0 otherwise

◆ RTPdfWritePort()

int RTPdfWritePort ( HANDLE  hPort,
const unsigned char *  pData,
unsigned long *  pdwDataSize 
)

Write a block of data to the specified file or port.

Parameters
hPortPointer to the file or port opened by the caller in RTPdfOpenPort
pDataPointer to the data to be written
pdwDataSizeOn input, number of bytes to write. On output, the caller should return the number of bytes actually written
Returns
int 1 if successful, 0 otherwise