10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8 The pCOS InterfaceThe pCOS (PDFlib Comprehensive Object Syntax) interface provides a simple and elegantfacility for retrieving arbitrary information from all sections of a PDF document whichdo not describe page contents, such as page dimensions, metadata, interactive elements,etc. pCOS users are assumed to have some basic knowledge of internal PDF structuresand dictionary keys, but do not have to deal with PDF syntax and parsing details.We strongly recommend that pCOS users obtain a copy of the PDF Reference, which isavailable as follows:Adobe Systems Incorporated: PDF Reference, Sixth Edition: Version 1.7. <strong>Download</strong>ablePDF from www.adobe.com/devnet/pdf/pdf_reference.html.8.1 Simple pCOS ExamplesCookbook A collection of pCOS coding fragments for solving specific problems can be found in thepCOS Cookbook.Assuming a valid PDF document handle is available, the pCOS functions PDF_pcos_get_number( ), PDF_pcos_get_string( ), and PDF_pcos_get_stream( ) can be used to retrieve informationfrom a PDF using the pCOS path syntax. Table 8.1 lists some common pCOSpaths and their meaning.Table 8.1 pCOS paths for commonly used PDF objectspCOS path type explanationlength:pages number number of pages in the document/Info/Title string document info field Title/Root/Metadata stream XMP stream with the document’s metadatafonts[...]/name string name of a font; the number of entries can be retrieved with length:fontsfonts[...]/embedded boolean embedding status of a fontpages[...]/width number width of the visible area of the pageNumber of pages.The total number of pages in a document can be queried as follows:pagecount = p.pcos_get_number(doc, "length:pages");Document information fields can be retrieved with the follow-Document info fields.ing code sequence:objtype = p.pcos_get_string(doc, "type:/Info/Title");if (objtype.equals("string")){/* Document info key found */title = p.pcos_get_string(doc, "/Info/Title");}Page size. Although the MediaBox, CropBox, and Rotate entries of a page can directly beobtained via pCOS, they must be evaluated in combination in order to find the actual8.1 Simple pCOS Examples 181

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

Saved successfully!

Ooh no, something went wrong!