DynaPDF Manual - Page 765

Previous Page 764   Index   Next Page 766

Function Reference
Page 765 of 770
Example (C++):
First, we define a structure which contains all variables we need to calculate the output rectangle. we
pass this structure to the SetOnPageBreakProc() function so that we don't need any global data.
struct TOutRect
void* iPDF;
// Active PDF instance
double PosX;
// X-coordinate of first output rectangle
double PosY;
// Y-coordinate of first output rectangle
double Width;
// Original width of the output rectangle
double Height;
// Original height of the output rectangle
double Distance; // Space between columns
SI32 Column;
// Current column
SI32 ColCount; // Number of columns
// This is our callback function
SI32 PDF_CALL OnPageBreakProc(const void* Data, double LastPosX, double
LastPosY, SI32 PageBreak)
TOutRect* r = (TOutRect*)Data; // get a pointer to our structure
pdfSetPageCoords(r->iPDF, pcTopDown); // we use top-down coordinates
if (!PageBreak && r->Column < r->ColCount -1)
// Calculate the x-coordinate of the column
double posX = r->PosX + r->Column * (r->Width + r->Distance);
// change the output rectangle, do not close the page!
pdfSetTextRect(r->iPDF, posX, r->PosY, r->Width, r->Height);
case 1: return NEW_ALIGN_JUSTIFY;
case 2: return NEW_ALIGN_RIGHT;
default: return 0; // do not change the alignment
// the page is full, close the current one and append a new page
pdfSetTextRect(r->iPDF, r->PosX, r->PosY, r->Width, r->Height);
r->Column = 0;

Previous topic: Escape Sequences, How to create multi-column text?

Next topic: WriteFTextEx, WriteText