Did you find this guide helpful?
Some test text!
iOS / Guides / Add layer
To add a PDF layer or OCG (optional content group) to a new document.
PTPDFDoc *doc = [[PTPDFDoc alloc] init];
PTElementBuilder *builder = [[PTElementBuilder alloc] init]; // ElementBuilder is used to build new Element objects
PTElementWriter *writer= [[PTElementWriter alloc] init]; // ElementWriter is used to write Elements to the page
// Create a layer
PTGroup *image_layer = [PTGroup Create: doc name: @"Image Layer"];
PTConfig *cfg = [PTConfig Create: doc default_config: YES];
[cfg SetName: @"Default"];
// Add the new OCG to the list of layers that should appear in PDF viewer GUI.
PTObj *layer_order_array = [doc CreateIndirectArray];
[cfg SetOrder: layer_order_array];
[layer_order_array PushBack: [image_layer GetSDFObj]];
// Start a new page
PTPage *page = [doc PageCreate: [[PTPDFRect alloc] initWithX1: 0 y1: 0 x2: 612 y2:792]];
[writer WriterBeginWithPage: page placement: e_ptoverlay page_coord_sys: YES compress: YES]; // Begin writing to the page
// Add new content to the page and associate it with one of the layers.
PTImage *img = [PTImage Create: [doc GetSDFDoc] filename: imagename];
[[img GetSDFObj] Put: @"OC" obj: image_layer];
[writer WritePlacedElement: [builder CreateImageWithCornerAndScale: img x: 300 y: 600 hscale: 200 vscale: -150]];
[writer End]; // save changes to the current page
[doc PagePushBack: page];
PDF layers (OCG)
Full sample code which demonstrates how to create, extract, render PDF layers.
Trial setup questions? Ask experts on Discord
Need other help? Contact Support
Pricing or product questions? Contact Sales