Components for Developers
© 2000-2012, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

PDF Creator Pilot documentation

Download CHM version of this manual.
How to Create Layers (Optional Contrent Groups) in PDF

Example
Collapse All

Example

C++

[copy to clipboard]
PM_DOCUMENT doc = PM_DOCUMENT_New();
PM_RECT rc = {0, 0, 500, 500};
PM_PAGE page = PM_DOCUMENT_AddPage(doc, rc);
PM_FONT font = PM_DOCUMENT_AddFont(doc, "Arial", true, false);
PM_CANVAS canvas = PM_PAGE_GetCanvas(page);

PM_OC_PROPERTIES pmOCProp = PM_DOCUMENT_CreateNewOptionalContentProperties(doc);

PM_OC_GROUP allContents = PM_OC_PROPERTIES_AddOCGroup(pmOCProp, "All Contents");
PM_CANVAS_BeginMarkedContent(canvas, allContents);

PM_OC_GROUP circle = PM_OC_PROPERTIES_AddOCGroup(pmOCProp, "Circle");

PM_CANVAS_BeginMarkedContent(canvas, circle);
PM_CANVAS_SetRGBColorFill(canvas, 1.0f, 0.0f, 0.0f);
PM_CANVAS_DrawCircle(canvas, 100, 100, 50);
PM_CANVAS_FillAndStroke(canvas);
PM_CANVAS_EndMarkedContent(canvas);

PM_OC_GROUP text = PM_OC_PROPERTIES_AddOCGroup(pmOCProp, "Text");

PM_CANVAS_BeginMarkedContent(canvas, text);
PM_CANVAS_SetRGBColorFill(canvas, 0.0f, 1.0f, 0.0f);
PM_CANVAS_UseFont(canvas, font, 16); 
PM_CANVAS_ShowText(canvas,rc.right/2, rc.bottom/2,"Text", 45);
PM_CANVAS_EndMarkedContent(canvas);
	
PM_CANVAS_EndMarkedContent(canvas);

PM_OC_CONFIG pmOCConfig = PM_OC_PROPERTIES_GetDefaultConfig(pmOCProp);
PM_OC_ORDER_COLLECTION	pmOCOrderCollection = PM_OC_CONFIG_GetOrder(pmOCConfig);
PM_OC_ORDER_COLLECTION_AddOCGroup(pmOCOrderCollection, allContents);
PM_OC_ORDER_COLLECTION_AddOCGroup(pmOCOrderCollection, circle);
PM_OC_ORDER_COLLECTION_AddOCGroup(pmOCOrderCollection, text);

PM_VIEWERPREF_SetPageMode(doc, pmUseOC);

PM_DOCUMENT_Save(doc, "AddLayers.pdf");
PM_DOCUMENT_Free(doc);

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF-X Pilot History In the Lab

 

 

PDF Library | Virtual Printer | Converters to PDF

Support | Blog | Forum | Contacts

© 2000-2012, Two Pilots