DynaPDF Manual - Page 171

Previous Page 170   Index   Next Page 172

Function Reference
Page 171 of 839
BeginLayer
Syntax:
LBOOL pdfBeginLayer(
const PPDF* IPDF, // Instance pointer
UI32 OCG)
// OCG or OCMD handle
The function opens a layer in the current open page or template. The layer must be closed with
EndLayer() when finish. The parameter OCG must be valid handle of an Optional Content Group
(OCG) or Optional Content Membership Dictionary (OCMD) (see CreateOCG() and CreateOCMD()
for further information). The OCG or OCMD controls the visibility of the contents that is included in
the layer.
BeginLayer() / EndLayer() calls connect normal page contents, such as text, images, and vector
graphics with a layer but no interactive objects like annotations or form fields. Annotations and
Form Fields can be added to a layer with AddObjectToLayer().
It is not required to draw the entire contents of a layer in one pass. The page contents can be drawn
as usual and delimited into BeginLayer() / EndLayer() calls as necessary. Only contents that is
delimited into BeginLayer() / EndLayer() calls becomes part of a layer.
Layers can be nested by calling BeginLayer() more than one time with different OCGs or OCMDs.
The visibility of an inner layer depends then also on the visibility of the out ones (see example
below). If an outer layer is invisible then all inner layers are invisible too, regardless of the visibility
settings of the inner layers.
Remarks:
A layer is not part of the graphics state. Neither BeginLayer() nor EndLayer() change any parameter
of the graphics state. BeginLayer() must not be called within an open path.
Return values:
If the function succeeds the return value is 1. If the function fails the return value is 0.
Example (C++):
pdfCreateNewPDF(pdf, "test_layer.pdf");
// We use three layers in this example
SI32 oc1 = pdfCreateOCG(pdf, "Anything", true, true, oiView);
SI32 oc2 = pdfCreateOCG(pdf, "Text and Annotations", true, true, oiView);
SI32 oc3 = pdfCreateOCG(pdf, "Images", true, true, oiView);
pdfSetPageCoords(pdf, pcTopDown);
pdfAppend(pdf);
// The main layer controls the visibility of all three layers in this
// example.
 

Previous topic: BeginClipPath (Obsolete), BeginContinueText

Next topic: BeginPageTemplate