[NTG-context] Pdf info: width, height and rotation

Procházka Lukáš Ing. LPr at pontex.cz
Thu Nov 17 09:27:01 CET 2016


Hello,

two questions about pages in PDF document (slightly refers to the code http://www.mail-archive.com/ntg-context@ntg.nl/msg57502.html):

----
local MyDocument = lpdf.epdf.load("A4.pdf")

context.starttext()

   local pages = MyDocument.pages
   local dummy = MyDocument.pages[1] -- we need lua 5.2 in order to avoid this

   local nofpages = #MyDocument.pages

   context.starttabulate { "|c|c|c|" }

     context.NC() context("page")
     context.NC() context("width")
     context.NC() context("height") context.NR()

     for i=1, nofpages do
         local page = pages[i]
         local bbox = page.CropBox or page.MediaBox
         context.NC() context(i)
         context.NC() context(bbox[4]-bbox[2])
         context.NC() context(bbox[3]-bbox[1]) context.NR()
     end

   context.stoptabulate()

context.stoptext()
----

The sample gives: w ~ 842 pt, h ~ 595 pt

Questions:

1. Shouldn't be width and height swapped? As the analyzed 'A4.pdf' has width of 210 mm and height of 297 mm, IOW width < height, whilst the cld code gives w > h (?!).

2. Is it possible to get rotation or orientation of the page (be "portrait" or "landscape" or "0" or "90" or so)?

3. Is the 'bbox' already affected by the page rotation/orientation? I mean - in the case page orientation is 90 or 270, is the width and height of 'bbox' swapped compared to the situation if page orientation was 0 (or 180)?

Best regards,

Lukas


-- 
Ing. Lukáš Procházka | mailto:LPr at pontex.cz
Pontex s. r. o.      | mailto:pontex at pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn
Bezová 1658
147 14 Praha 4

Tel: +420 241 096 751 (+420 720 951 172)
Fax: +420 244 461 038
-------------- next part --------------
A non-text attachment was scrubbed...
Name: A4.pdf
Type: application/pdf
Size: 2947 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20161117/41c0fd1e/attachment.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PdfInfo.cld
Type: application/octet-stream
Size: 697 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20161117/41c0fd1e/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PdfInfo.pdf
Type: application/pdf
Size: 6686 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20161117/41c0fd1e/attachment-0001.pdf>


More information about the ntg-context mailing list