* OT: Pdf info
@ 2011-07-20 11:21 Procházka Lukáš Ing. - Pontex s. r. o.
2011-07-20 11:27 ` Taco Hoekwater
2011-07-20 11:29 ` luigi scarso
0 siblings, 2 replies; 9+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2011-07-20 11:21 UTC (permalink / raw)
To: ConTeXt
Hello,
this question in not straightly related to Context, but Context users may have solved it and Ctx may be used to solve it.
I would need to get the following information from .pdf file(s):
- number of pages,
- common width and height of pages (provided that they are the same; otherwise the dimension can be e.g. zero).
The final goal is to use Ctx as a .pdf joining engine - to provide this, I need to know whether the .pdf to be inserted is portrait or landscape oriented, what is its size (so if to be scaled or not) etc.
So Lua inside Ctx may be used to get the required .pdf info, if necessary.
If an external program was used, it should be non-interactive (command-line oriented), free and working under Windows.
Does anyone have any experience with such a task?
Kind regards,
Lukas
--
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4
Tel: +420 244 062 238
Fax: +420 244 461 038
___________________________________________________________________________________
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: OT: Pdf info
2011-07-20 11:21 OT: Pdf info Procházka Lukáš Ing. - Pontex s. r. o.
@ 2011-07-20 11:27 ` Taco Hoekwater
2011-07-20 11:29 ` luigi scarso
1 sibling, 0 replies; 9+ messages in thread
From: Taco Hoekwater @ 2011-07-20 11:27 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 07/20/11 13:21, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
> Hello,
>
> this question in not straightly related to Context, but Context users
> may have solved it and Ctx may be used to solve it.
>
> I would need to get the following information from .pdf file(s):
>
> - number of pages,
> - common width and height of pages (provided that they are the same;
> otherwise the dimension can be e.g. zero).
There is the macro \getfiguredimensions which, amongst other things,
sets up \noffigurepages, \figurewidth, and \figureheight.
Here is an excerpt from a macro I have been using since 'forever':
\newcount\imgcount % to store the number of pages
\unexpanded\def\addimage#1{%
\getfiguredimensions[#1.pdf]%
\imgcount=\noffigurepages\relax
\dorecurse
{\the\imgcount}
{\getfiguredimensions[#1.pdf][page=\recurselevel]%
\ifdim\figurewidth>\figureheight
...
\fi }}
Best wishes,
Taco
___________________________________________________________________________________
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: OT: Pdf info
2011-07-20 11:21 OT: Pdf info Procházka Lukáš Ing. - Pontex s. r. o.
2011-07-20 11:27 ` Taco Hoekwater
@ 2011-07-20 11:29 ` luigi scarso
2011-07-20 12:02 ` Hartmut Henkel
2011-07-20 12:54 ` OT: Pdf info (solved) Procházka Lukáš Ing. - Pontex s. r. o.
1 sibling, 2 replies; 9+ messages in thread
From: luigi scarso @ 2011-07-20 11:29 UTC (permalink / raw)
To: mailing list for ConTeXt users
2011/7/20 Procházka Lukáš Ing. - Pontex s. r. o. <LPr@pontex.cz>:
> Hello,
>
> this question in not straightly related to Context, but Context users may
> have solved it and Ctx may be used to solve it.
>
> I would need to get the following information from .pdf file(s):
>
> - number of pages,
> - common width and height of pages (provided that they are the same;
> otherwise the dimension can be e.g. zero).
>
> The final goal is to use Ctx as a .pdf joining engine - to provide this, I
> need to know whether the .pdf to be inserted is portrait or landscape
> oriented, what is its size (so if to be scaled or not) etc.
>
> So Lua inside Ctx may be used to get the required .pdf info, if necessary.
>
> If an external program was used, it should be non-interactive (command-line
> oriented), free and working under Windows.
>
> Does anyone have any experience with such a task?
You can use some macros (see Taco), and for external programs
google for mupdf and xpdf
Tthe lua pdf library with mkiv should be also useful, but I've still
to play with it.
--
luigi
___________________________________________________________________________________
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: OT: Pdf info
2011-07-20 11:29 ` luigi scarso
@ 2011-07-20 12:02 ` Hartmut Henkel
2011-07-20 12:11 ` luigi scarso
` (2 more replies)
2011-07-20 12:54 ` OT: Pdf info (solved) Procházka Lukáš Ing. - Pontex s. r. o.
1 sibling, 3 replies; 9+ messages in thread
From: Hartmut Henkel @ 2011-07-20 12:02 UTC (permalink / raw)
To: mailing list for ConTeXt users, ntg-context
> 2011/7/20 Procházka Lukáš Ing. - Pontex s. r. o. <LPr@pontex.cz>:
> > Hello,
> >
> > this question in not straightly related to Context, but Context users
> may
> > have solved it and Ctx may be used to solve it.
> >
> > I would need to get the following information from .pdf file(s):
> >
> > - number of pages,
> > - common width and height of pages (provided that they are the same;
> > otherwise the dimension can be e.g. zero).
> >
> > The final goal is to use Ctx as a .pdf joining engine - to provide this,
> I
> > need to know whether the .pdf to be inserted is portrait or landscape
> > oriented, what is its size (so if to be scaled or not) etc.
> >
> > So Lua inside Ctx may be used to get the required .pdf info, if
> necessary.
> >
> > If an external program was used, it should be non-interactive
> (command-line
> > oriented), free and working under Windows.
> >
> > Does anyone have any experience with such a task?
> You can use some macros (see Taco), and for external programs
> google for mupdf and xpdf
>
> Tthe lua pdf library with mkiv should be also useful, but I've still
> to play with it.
luatex's epdf library (= poppler Lua bindings, maybe that's what Luigi meant) allows to extract all this info from a pdf file, with a bit of Lua programming.
Regards, Hartmut
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
___________________________________________________________________________________
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: OT: Pdf info
2011-07-20 12:02 ` Hartmut Henkel
@ 2011-07-20 12:11 ` luigi scarso
2011-07-20 12:26 ` Procházka Lukáš Ing. - Pontex s. r. o.
2011-07-20 12:53 ` Hans Hagen
2 siblings, 0 replies; 9+ messages in thread
From: luigi scarso @ 2011-07-20 12:11 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Wed, Jul 20, 2011 at 2:02 PM, Hartmut Henkel <hartmut_henkel@gmx.de> wrote:
> luatex's epdf library (= poppler Lua bindings, maybe that's what Luigi meant) allows to extract all this info from a pdf file, with a bit of Lua programming.
Yes, I meant the epdf library.
--
luigi
___________________________________________________________________________________
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: OT: Pdf info
2011-07-20 12:02 ` Hartmut Henkel
2011-07-20 12:11 ` luigi scarso
@ 2011-07-20 12:26 ` Procházka Lukáš Ing. - Pontex s. r. o.
2011-07-20 12:53 ` Hans Hagen
2 siblings, 0 replies; 9+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2011-07-20 12:26 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Wed, 20 Jul 2011 14:02:00 +0200, Hartmut Henkel <hartmut_henkel@gmx.de> wrote:
>> The lua pdf library with mkiv should be also useful, but I've still
>> to play with it.
>
> luatex's epdf library (= poppler Lua bindings, maybe that's what Luigi meant) allows to extract all this info from a pdf file, with a bit of Lua programming.
>
> Regards, Hartmut
Hello,
would you provide a minimal example - if it is possible in the Ctx or Lua scope? Something like:
----
\startluacode
local info = SOMETHING.getInfo("File.pdf")
local n = info.numPages
local w = info.width
local h = info.height
\stopluacode
----
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: OT: Pdf info
2011-07-20 12:02 ` Hartmut Henkel
2011-07-20 12:11 ` luigi scarso
2011-07-20 12:26 ` Procházka Lukáš Ing. - Pontex s. r. o.
@ 2011-07-20 12:53 ` Hans Hagen
2011-07-20 13:04 ` Procházka Lukáš Ing. - Pontex s. r. o.
2 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2011-07-20 12:53 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Hartmut Henkel
On 20-7-2011 2:02, Hartmut Henkel wrote:
>> 2011/7/20 Procházka Lukáš Ing. - Pontex s. r. o.<LPr@pontex.cz>:
>>> Hello,
>>>
>>> this question in not straightly related to Context, but Context users
>> may
>>> have solved it and Ctx may be used to solve it.
>>>
>>> I would need to get the following information from .pdf file(s):
>>>
>>> - number of pages,
>>> - common width and height of pages (provided that they are the same;
>>> otherwise the dimension can be e.g. zero).
>>>
>>> The final goal is to use Ctx as a .pdf joining engine - to provide this,
>> I
>>> need to know whether the .pdf to be inserted is portrait or landscape
>>> oriented, what is its size (so if to be scaled or not) etc.
>>>
>>> So Lua inside Ctx may be used to get the required .pdf info, if
>> necessary.
>>>
>>> If an external program was used, it should be non-interactive
>> (command-line
>>> oriented), free and working under Windows.
>>>
>>> Does anyone have any experience with such a task?
>> You can use some macros (see Taco), and for external programs
>> google for mupdf and xpdf
>>
>> Tthe lua pdf library with mkiv should be also useful, but I've still
>> to play with it.
>
> luatex's epdf library (= poppler Lua bindings, maybe that's what Luigi meant) allows to extract all this info from a pdf file, with a bit of Lua programming.
indeed (although we still need to fill in some gaps)
anyhow:
local MyDocument = lpdf.epdf.load("sometext.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()
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| 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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: OT: Pdf info (solved)
2011-07-20 11:29 ` luigi scarso
2011-07-20 12:02 ` Hartmut Henkel
@ 2011-07-20 12:54 ` Procházka Lukáš Ing. - Pontex s. r. o.
1 sibling, 0 replies; 9+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2011-07-20 12:54 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hello,
On Wed, 20 Jul 2011 13:29:35 +0200, luigi scarso <luigi.scarso@gmail.com> wrote:
> You can use some macros (see Taco), and for external programs
> google for mupdf and xpdf
I installed "Xpdf for Windows" - http://gnuwin32.sourceforge.net/packages/xpdf.htm - and "pdfinfo.exe" does the job:
----
C:\Programs.Con\Gnu4Win\XPdf\bin>pdfinfo c:\Lukas\Jobs\Drachov.PDPS\SO_126\Texts\TZ#.pdf
Creator: pdftk 1.41 - www.pdftk.com
Producer: itext-paulo-155 (itextpdf.sf.net-lowagie.com)
CreationDate: 05/18/11 17:15:13
ModDate: 05/18/11 17:15:13
Tagged: no
Pages: 8
Encrypted: no
Page size: 595 x 842 pts (A4)
File size: 119898 bytes
Optimized: no
PDF version: 1.4
----
Thanks all for their help.
Best regards,
Lukas
--
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o. [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4
Tel: +420 244 062 238
Fax: +420 244 461 038
___________________________________________________________________________________
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: OT: Pdf info
2011-07-20 12:53 ` Hans Hagen
@ 2011-07-20 13:04 ` Procházka Lukáš Ing. - Pontex s. r. o.
0 siblings, 0 replies; 9+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2011-07-20 13:04 UTC (permalink / raw)
To: mailing list for ConTeXt users
> local MyDocument = lpdf.epdf.load("sometext.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()
This code works perfectly, thank you Hans!
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-07-20 13:04 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-20 11:21 OT: Pdf info Procházka Lukáš Ing. - Pontex s. r. o.
2011-07-20 11:27 ` Taco Hoekwater
2011-07-20 11:29 ` luigi scarso
2011-07-20 12:02 ` Hartmut Henkel
2011-07-20 12:11 ` luigi scarso
2011-07-20 12:26 ` Procházka Lukáš Ing. - Pontex s. r. o.
2011-07-20 12:53 ` Hans Hagen
2011-07-20 13:04 ` Procházka Lukáš Ing. - Pontex s. r. o.
2011-07-20 12:54 ` OT: Pdf info (solved) Procházka Lukáš Ing. - Pontex s. r. o.
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).