3

I have not long ago post a quesion about how to use the optional content group in pdf. But now I have a new question. How to make these optional content group in a tree structure.

For example. I have 4 different layers. these layers are all OCG layer. 3 layers is text labels, 1 layer have veccotr graphic. So i want it shown as this:

Alllayers
   ---labels
       --layer1
       --layer2
       --layer3
   ---layer4

I use a pdf doc as an example enter image description here

this is in chinese, the chinses character is the name of the layer. Just this meaning.

Tobias Kienzler
  • 25,759
  • 22
  • 127
  • 221
user1279988
  • 757
  • 1
  • 11
  • 27

1 Answers1

4

The answer to this question will depend on which pdf library you are using to generate your files. In general, you will need to produce a file that has an Order array in the optional content configuration dictionary that represents the tree that you want to display.

From the PDF Reference Document:

Key: Order
Type: array
Description: (Optional) An array specifying the order for presentation of optional content groups in a conforming reader’s user interface. The array elements may include the following objects:
-Optional content group dictionaries, whose Name entry shall bedisplayed in the user interface by the conforming reader.
-Arrays of optional content groups which may be displayed by a conforming reader in a tree or outline structure. Each nested array may optionally have as its first element a text string to be used as a non-selectable label in a conforming reader’s user interface.

yms
  • 10,361
  • 3
  • 38
  • 68
  • do you have any pdf lib for reconmend? I use quickpdf lib and have not found the related fucntion. libharu and libcairo even no funciton to setup optional content group. – user1279988 Jan 29 '13 at 17:19
  • I actually work in development of a commercial library called Amyuni PDF Converter (a virtual printer for Windows) that allows to do this if the file is created by the library from scratch. But editing the layers configuration from existing files is not currently supported. I do not know about any other C++ library that allows you to this. – yms Jan 29 '13 at 17:57
  • If an AGPL license works for you, [you might be able to do this with iText](http://api.itextpdf.com/itext/com/itextpdf/text/pdf/PdfWriter.html#documentOCGorder) in Java or with iTextSharp in C#/VB.Net/Python.Net etc. You could even attempt to wrap the process in a native library by embedding the mono framework in it. – yms Jan 29 '13 at 18:04
  • I am not editing. I just want to assign the config OK when creating. My project is work in c/c++, so I face such a problem. And if let me add the OCG function modifing these opensource pdf lib, the work is so hard for me. – user1279988 Jan 29 '13 at 18:16