
Adobe Acrobat SDK
Inserting Text into PDF Documents
Developing Plug-ins and Applications
Examining a PDF Library application source file 69
#include "PagePDECntCalls.h"
#ifdef MAC_ENV
#include "macUtils.h"
#endif
void MainProc(void)
{
char buf[256];
ASInt32 i;
ASBool b;
PDDoc pdDoc; /* Reference to a PDF document */
PDPage pdPage; /* Reference to a page in doc */
PDEContent pdeContent; /* Container for page content */
ASFixedRect mediaBox; /* Dimensions of page */
PDSysFont sysFont; /* Used by PDEFont creation */
PDEFont pdeFont; /* Reference to a font used on a page */
PDEFontAttrs pdeFontAttrs; /* Font attributes */
PDEText pdeText; /* Container for text */
ASFixedMatrix textMatrix; /* Transformation matrix for text */
PDEColorSpace pdeColorSpace; /* ColorSpace */
PDEGraphicState gState; /* Graphic state to apply to operation */
char *HelloWorldStr = "Hello There"; // Text to write to the PDF
#ifdef MAC_ENV
ASPathName macPath;
#endif
/*==================================================================*\
Create the doc, page, and content container
\*==================================================================*/
DURING
pdDoc = PDDocCreate(); /* Create new document */
mediaBox.left = fixedZero; /* Dimensions of page */
mediaBox.top = Int16ToFixed(4*72); /* In this case 5" x 4" */
mediaBox.right = Int16ToFixed(5*72);
mediaBox.bottom = fixedZero;
//Create a page with those dimensions and insert it as the first page
pdPage = PDDocCreatePage(pdDoc, PDBeforeFirstPage, mediaBox);
//Acquire a PDEContent container for the page
pdeContent = PDPageAcquirePDEContent(pdPage, NULL);
/*==================================================================*\
Acquire a font, add text, and insert into page content container
\*==================================================================*/
//Set the size of the PDSysFont and set its attributes
memset(&pdeFontAttrs, 0, sizeof(pdeFontAttrs));
pdeFontAttrs.name = ASAtomFromString("CourierStd");