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.

3.2 Page Descriptions3.2.1 Coordinate SystemsPDF’s default coordinate system is used within PDFlib. The default coordinate system(or default user space) has the origin in the lower left corner of the page, and uses theDTP point as unit:1 pt = 1/72 inch = 25.4/72 mm = 0.3528 mmThe first coordinate increases to the right, the second coordinate increases upwards.PDFlib client programs may change the default user space by rotating, scaling, translating,or skewing, resulting in new user coordinates. The respective functions for thesetransformations are PDF_rotate( ), PDF_scale( ), PDF_translate( ), and PDF_skew( ). If the coordinatesystem has been transformed, all coordinates in graphics and text functionsmust be supplied according to the new coordinate system. The coordinate system is resetto the default coordinate system at the start of each page.Using metric coordinates. Metric coordinates can easily be used by scaling the coordinatesystem. The scaling factor is derived from the definition of the DTP point givenabove:p.scale(28.3465, 28.3465);After this call PDFlib will interpret all coordinates (except for interactive features, seebelow) in centimeters since 72/2.54 = 28.3465.As an alternative, the userunit option in PDF_begin/end_page_ext( ) (PDF 1.6) can bespecified to supply a scaling factor for the whole page. Note that user units will only affectfinal page display in Acrobat, but not any coordinate scaling in PDFlib.Cookbook A full code sample can be found in the Cookbook topic general/metric_topdown_coordinates.Coordinates for interactive elements. PDF always expects coordinates for interactivefunctions, such as the rectangle coordinates for creating text annotations, links, and fileannotations in the default coordinate system, and not in the (possibly transformed)user coordinate system. Since this is very cumbersome PDFlib offers automatic conversionof user coordinates to the format expected by PDF. This automatic conversion is activatedby setting the usercoordinates parameter to true:p.set_parameter("usercoordinates", "true");Since PDF supports only link and field rectangles with edges parallel to the page edges,the supplied rectangles must be modified when the coordinate system has been transformedby scaling, rotating, translating, or skewing it. In this case PDFlib will calculatethe smallest enclosing rectangle with edges parallel to the page edges, transform it todefault coordinates, and use the resulting values instead of the supplied coordinates.The overall effect is that you can use the same coordinate systems for both page contentand interactive elements when the usercoordinates parameter has been set to true.Visualizing coordinates. In order to assist PDFlib users in working with PDF’s coordinatesystem, the PDFlib distribution contains the PDF file grid.pdf which visualizes the54 Chapter 3: PDFlib Programming

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

Saved successfully!

Ooh no, something went wrong!