Xojo Conferences
MBSOct2019CologneDE

DynaPDF Manual - Page 766

Previous Page 765   Index   Next Page 767

Function Reference
Page 766 of 770
// First we declare an error callback function.
SI32 PDF_CALL PDFError(const void* Data, SI32 ErrCode, const char*
ErrMessage, SI32 ErrType)
{
printf("%s\n", ErrMessage); return 0;
}
int main(int argc, char* argv[])
{
// The structure TOutRect holds all required variables to calculate
// the output rectangle.
TOutRect r;
// The text is stored in a text file
FILE* f = fopen("c:/sample.txt", "rb");
if (f == NULL) return 2;
char* fText;
UI32 bufSize;
fseek(f, 0, SEEK_END);
bufSize = ftell(f);
fseek(f, 0, SEEK_SET);
// allocate one more character for the null-terminator
fText = (char*)malloc(bufSize +1);
fread(fText, 1, bufSize, f);
fclose(f);
fText[bufSize] = 0;
// Do NOT forget to add a null-terminator!!!
r.iPDF = pdfNewPDF(); // Get a new PDF instance
if (!r.iPDF)
// Out of memory?
{
free(fText);
return 2;
}
pdfSetOnErrorProc(r.iPDF, NULL, PDFError);
pdfSetDocInfo(r.iPDF, diCreator, "C++ test app");
pdfSetDocInfo(r.iPDF, diSubject, "Multi-column text");
pdfSetDocInfo(r.iPDF, diTitle, " Multi-column text ");
// We use top-down coordinates
pdfSetPageCoords(r.iPDF, pcTopDown);
pdfCreateNewPDF(r.iPDF, "c:/cppout.pdf");
pdfAppend(r.iPDF);
pdfSetFont(r.iPDF, "Arial", fsNone, 8.0, true, cp1252);
r.ColCount = 3;
r.Column
= 0;
r.Distance = 5.0;
r.PosX
= 50.0;
 

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

Next topic: WriteFTextEx, WriteText