DynaPDF Manual - Page 163

Previous Page 162   Index   Next Page 164

Function Reference
Page 163 of 839
ApplyShading
Syntax:
SI32 pdfApplyShading(
const PPDF* IPDF, // Instance pointer
SI32 ShadHandle)
// Handle of the shading
This function applies a shading to the current clipping path, or if no clipping is active, to the entire
page. See also CreateAxialShading(), CreateRadialShading().
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
Example (C):
// First we declare our 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[])
{
SI32 sh;
void* pdf = pdfNewPDF();
if (!pdf) return 2; // Out of memory?
pdfSetOnErrorProc(pdf, NULL, PDFError);
pdfSetDocInfo(pdf, diAuthor, "Jens Boschulte");
pdfSetDocInfo(pdf, diCreator, "C sample project");
pdfSetDocInfo(pdf, diSubject, "How to use shadings");
pdfSetDocInfo(pdf, diTitle, "Shadings");
// we use top-down coordinates
pdfSetPageCoords(pdf, pcTopDown);
pdfCreateNewPDF(pdf, "c:/cppout.pdf");
pdfAppend(pdf);
pdfSaveGraphicState(pdf);
pdfBeginClipPath(pdf);
pdfRectangle(pdf, 50, 50, 200, 30, fmNoFill);
pdfClipPath(pdf, cmWinding, fmFill);
sh = pdfCreateAxialShading(pdf, 50, 0, 250, 0, 1.5, PDF_WHITE,
PDF_BLUE, false, false);
pdfApplyShading(pdf, sh);
pdfRestoreGraphicState(pdf);
 

Previous topic: ApplyAppEvent, ApplyPattern

Next topic: AssociateEmbFile