* Pdf info: width, height and rotation
@ 2016-11-17 8:27 Procházka Lukáš Ing.
2016-11-17 8:51 ` Hans Hagen
0 siblings, 1 reply; 3+ messages in thread
From: Procházka Lukáš Ing. @ 2016-11-17 8:27 UTC (permalink / raw)
To: ConTeXt
[-- Attachment #1: Type: text/plain, Size: 1700 bytes --]
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@pontex.cz
Pontex s. r. o. | mailto:pontex@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
[-- Attachment #2: A4.pdf --]
[-- Type: application/pdf, Size: 2947 bytes --]
[-- Attachment #3: PdfInfo.cld --]
[-- Type: application/octet-stream, Size: 697 bytes --]
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()
[-- Attachment #4: PdfInfo.pdf --]
[-- Type: application/pdf, Size: 6686 bytes --]
[-- Attachment #5: Type: text/plain, Size: 492 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Pdf info: width, height and rotation
2016-11-17 8:27 Pdf info: width, height and rotation Procházka Lukáš Ing.
@ 2016-11-17 8:51 ` Hans Hagen
2016-11-17 9:16 ` Procházka Lukáš Ing.
0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2016-11-17 8:51 UTC (permalink / raw)
To: mailing list for ConTeXt users
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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-17 9:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-17 8:27 Pdf info: width, height and rotation Procházka Lukáš Ing.
2016-11-17 8:51 ` Hans Hagen
2016-11-17 9:16 ` Procházka Lukáš Ing.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).