ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Pdf info: width, height and rotation
Date: Thu, 17 Nov 2016 09:51:51 +0100	[thread overview]
Message-ID: <94a35210-4fc8-220a-f211-ed48af29662c@wxs.nl> (raw)
In-Reply-To: <op.yq2cfbh862epfj@lpr>

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
___________________________________________________________________________________

  reply	other threads:[~2016-11-17  8:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-17  8:27 Procházka Lukáš Ing.
2016-11-17  8:51 ` Hans Hagen [this message]
2016-11-17  9:16   ` Procházka Lukáš Ing.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=94a35210-4fc8-220a-f211-ed48af29662c@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).