pdfGetLayerOrderName
Get the name of a layer display order node.
char *pdfGetLayerOrderName(PDFHandle pdf, PDFLayerOrderHandle order, int *length)
PDF files with layers contain a tree structure that specifies the way
layers are intended to be displayed to the user. Each node in the tree
has either a name or a layer. Named nodes are used to provide a
hierarchical structure for the layers, with labels to help the
user. Each node also optionally has a list of child nodes.
This function returns the name associated with the specified layer
order tree node. It should only be called if
pdfGetLayerOrderIsName
returns non-zero for the node.
The name is converted according to the current text encoding (see
pdfSetTextEncoding
).
The caller is responsible for freeing the name string after using it,
by calling pdfFreeMemory
.
C:
scanLayerOrder(pdfGetLayerOrderRoot(pdf));
...
void scanLayerOrder(PDFLayerOrderHandle order) {
char *name;
int length;
PDFLayerHandle layer;
int nChildren, i;
if (pdfGetLayerOrderIsName(pdf, order)) {
/* this node has a name */
name = pdfGetLayerOrderName(pdf, order, &length);
...
pdfFreeMemory(name);
} else {
/* this node has a layer */
layer = pdfGetLayerOrderLayer(pdf, order);
...
}
nChildren = pdfGetLayerOrderNumChildren(pdf, order);
for (i = 0; i < nChildren; ++i) {
scanLayerOrder(pdfGetLayerOrderChild(pdf, order, i);
}
}