17.05.2014 Views

PDFlib Text Extraction Toolkit (TET) Manual

PDFlib Text Extraction Toolkit (TET) Manual

PDFlib Text Extraction Toolkit (TET) Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Page size. Although the MediaBox, CropBox, and Rotate entries of a page can directly be<br />

obtained via pCOS, they must be evaluated in combination in order to find the actual<br />

size of a page. Determining the page size is much easier with the width and height keys<br />

of the pages pseudo object. The following code retrieves the width and height of page 3<br />

(note that indices for the pages pseudo object start at 0):<br />

pagenum = 2<br />

width = tet.pcos_get_number(doc, "pages[" + pagenum + "]/width");<br />

height = tet.pcos_get_number(doc, "pages[" + pagenum + "]/height");<br />

Listing all fonts in a document. The following sequence creates a list of all fonts in a<br />

document along with their embedding status:<br />

fontcount = tet.pcos_get_number(doc, "length:fonts");<br />

for (i=0; i < fontcount; i++)<br />

{<br />

fontname = tet.pcos_get_string(doc, "fonts[" + i + "]/name");<br />

embedded = tet.pcos_get_number(doc, "fonts[" + i + "]/embedded");<br />

}<br />

Writing mode. Using pCOS and the fontid value provided in the char_info structure<br />

you can easily check whether a font uses vertical writing mode:<br />

if (tet.pcos_get_number(doc, "fonts[" + ci->fontid + "]/vertical"))<br />

{<br />

/* font uses vertical writing mode */<br />

}<br />

Encryption status. You can query the pcosmode pseudo object to determine the pCOS<br />

mode for the document:<br />

if (tet.pcos_get_number(doc, "pcosmode") == 2)<br />

{<br />

/* full pCOS mode */<br />

}<br />

XMP meta data. A stream containing XMP meta data can be retrieved with the following<br />

code sequence:<br />

objtype = tet.pcos_get_string(doc, "type:/Root/Metadata");<br />

if (objtype.equals("stream"))<br />

{<br />

/* XMP meta data found */<br />

metadata = tet.pcos_get_stream(doc, "", "/Root/Metadata");<br />

}<br />

106 Chapter 9: The pCOS Interface

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!