On 11/17/2016 9:27 AM, Procházka Lukáš Ing. wrote:
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 (?!).
you do that yourself as [3] - [1] is the width while you put it under height
2. Is it possible to get rotation or orientation of the page (be "portrait" or "landscape" or "0" or "90" or so)?
if it's in a dictionary you can locate it query the value
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)?
I don't know.
Best regards,
Lukas
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------