DynaPDF Manual - Page 743

Previous Page 742   Index   Next Page 744

Function Reference
Page 743 of 787
int main(int argc, char* argv[])
{
void* pdf = pdfNewPDF();
if (!pdf) return 2; // Out of memory?
pdfSetOnErrorProc(pdf, NULL, PDFError);
// The document info entries are changed by the function if set
pdfSetDocInfo(pdf, diSubject, "Text as clipping path");
pdfSetDocInfo(pdf, diCreator, "C++ example test project");
pdfSetDocInfo(pdf, diTitle, "Text as clipping path");
pdfSetPageCoords(pdf, pcTopDown);
pdfCreateNewPDF(pdf, "c:/cppout.pdf");
pdfAppend(pdf);
pdfSetFont(pdf, "Bookman Old Style", fsBold, 80, true, cp1252);
// We want to draw an axial shading into the clipping path
SI32 sh = pdfCreateAxialShading(pdf, 0, 50, 0, 130, 1, PDF_BLUE,
PDF_YELLOW, false, false);
// Do not forget to save the graphics state
pdfSaveGraphicState(pdf);
pdfSetTextDrawMode(pdf, dmClipping); // Use the text as clipping path
pdfWriteText(pdf, 50, 50 - (80 - pdfGetCapHeight()), "Clipping");
pdfApplyShading(pdf, sh);
// Restore the graphics state now to disable the clipping path
pdfRestoreGraphicState(pdf);
EndPage(pdf);
pdfCloseFile(pdf);
pdfDeletePDF(pdf); // Do not forget to delete the PDF instance
return 0;
}
Output:
 

Previous topic: How to use text as clipping path?

Next topic: SetTextFieldValue, SetTextFieldValueEx

Start Chat