Page count of PDF file from lua
I can't figure out how to determine the number of pages of a PDF file within lua. From the TeX side it works with \getfiguredimensions Can somebody give me a nudge in the right direction? Example: \starttext % Works %\getfiguredimensions [somefile.pdf] \startluacode -- Does not work context.getfiguredimensions({"somefile.pdf"}) local numpages = figures.get("used", "pages", 0) context(numpages) \stopluacode \stoptext Marco
On 19-2-2012 14:50, Marco wrote:
I can't figure out how to determine the number of pages of a PDF file within lua. From the TeX side it works with \getfiguredimensions
Can somebody give me a nudge in the right direction? Example:
\starttext
% Works %\getfiguredimensions [somefile.pdf]
\startluacode -- Does not work context.getfiguredimensions({"somefile.pdf"})
local numpages = figures.get("used", "pages", 0) context(numpages) \stopluacode
\stoptext
something local fig = figures.push { name = "somefile.pdf" } figures.identify() figures.check() local nofpages = fig.used.pages figures.pop() ----------------------------------------------------------------- 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 -----------------------------------------------------------------
On 2012-02-21 Hans Hagen
I can't figure out how to determine the number of pages of a PDF file within lua.
local fig = figures.push { name = "somefile.pdf" } figures.identify() figures.check() local nofpages = fig.used.pages figures.pop()
Thanks for the snippet, Hans. Marco
... Some solutions can be found here, too:
http://www.mail-archive.com/ntg-context@ntg.nl/msg57502.html
http://www.mail-archive.com/ntg-context@ntg.nl/msg57503.html
Lukas
On Tue, 21 Feb 2012 13:40:26 +0100, Hans Hagen
On 19-2-2012 14:50, Marco wrote:
I can't figure out how to determine the number of pages of a PDF file within lua. From the TeX side it works with \getfiguredimensions
Can somebody give me a nudge in the right direction? Example:
\starttext
% Works %\getfiguredimensions [somefile.pdf]
\startluacode -- Does not work context.getfiguredimensions({"somefile.pdf"})
local numpages = figures.get("used", "pages", 0) context(numpages) \stopluacode
\stoptext
something
local fig = figures.push { name = "somefile.pdf" } figures.identify() figures.check() local nofpages = fig.used.pages figures.pop()
----------------------------------------------------------------- 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 ___________________________________________________________________________________
-- 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
On 2012-02-22 Procházka Lukáš Ing. - Pontex s. r. o.
... Some solutions can be found here, too:
http://www.mail-archive.com/ntg-context@ntg.nl/msg57502.html http://www.mail-archive.com/ntg-context@ntg.nl/msg57503.html
Thanks, Lukáš. That also works. Unfortunately, I didn't find the thread while searching the list. I did a quick benchmark which revealed that both solutions perform almost the same. I guess they use the same backend code. Marco
Having an issue in my pdf-output after processing a markdown file to .tex --> .pdf It adds the word "stylecolors" in the .pdf file Why is it doing that? Jan-Eriks-Mac-mini:test-markdown janneman$ context --version mtx-context | main context file: /Users/janneman/context/tex/texmf-context/tex/context/base/context.mkiv mtx-context | current version: 2011.05.18 18:04 Jan-Eriks-Mac-mini:test-markdown janneman$ Jan-Eriks-Mac-mini:test-markdown janneman$ kpsewhich t-filter.mkiv /Users/janneman/context/tex/texmf-modules/tex/context/third/filter/t-filter.mkiv Jan-Eriks-Mac-mini:test-markdown janneman$ Jan-Eriks-Mac-mini:test-markdown janneman$ pandoc --version pandoc 1.8.2 Compiled with citeproc support. Compiled with syntax highlighting support for: Actionscript, Ada, Alert, Alert_indent, Ansys, Apache, Asn1, Asp, Awk, Bash, Bibtex, Boo, C, Changelog, Cisco, Cmake, Coffeescript, Coldfusion, Commonlisp, Cpp, Cs, Css, Cue, D, Desktop, Diff, Djangotemplate, Doxygen, Doxygenlua, Dtd, Eiffel, Email, Erlang, Fortran, Fsharp, Fstab, Gap, Gdb, Gettext, Gnuassembler, Go, Haskell, Haxe, Html, Idl, Ilerpg, Ini, Java, Javadoc, Javascript, Json, Jsp, Latex, Lex, LiterateHaskell, Lua, M3u, Makefile, Mandoc, Matlab, Maxima, Mediawiki, Metafont, Mips, Modula2, Modula3, Monobasic, Nasm, Noweb, Objectivec, Objectivecpp, Ocaml, Octave, Pango, Pascal, Perl, Php, Pike, Postscript, Prolog, Python, R, Relaxngcompact, Rhtml, Ruby, Scala, Scheme, Sci, Sed, Sgml, Sql, SqlMysql, SqlPostgresql, Tcl, Texinfo, Verilog, Vhdl, Winehq, Wml, Xharbour, Xml, Xorg, Xslt, Xul, Yacc, Yaml Copyright (C) 2006-2011 John MacFarlane Web: http://johnmacfarlane.net/pandoc This is free software; see the source for copying conditions. There is no warranty, not even for merchantability or fitness for a particular purpose. I am having all these installed on mac osx 10.7 lion Thanks in advance Jan-Erik Hägglöf Generated .tex file by output from pandoc Log messages
On Wed, 22 Feb 2012, Jan-Erik Hägglöf wrote:
Having an issue in my pdf-output after processing a markdown file to .tex --> .pdf
It adds the word "stylecolors" in the .pdf file
Why is it doing that?
Possibly because there was a bug in the version of the filter module (2011.12.17) that you are using. It works fine with version (2012.01.26) or (2012.02.11). The easiest fix is to update your context distribution and get the latest version of the module. If you don't want to update the entire distribution, just get the latest version of t-filter.mkiv, t-module-catcodes.tex from https://github.com/adityam/filter; Although I haven't tested if the latest version of the filter module works with old ConTeXt format. You are using 2011.05.18 and lots of ConTeXt internals have changed since then. The other option will be to pick an old version of the module: https://github.com/adityam/filter/tags Aditya
On Wed, 22 Feb 2012, Aditya Mahajan wrote:
On Wed, 22 Feb 2012, Jan-Erik Hägglöf wrote:
Having an issue in my pdf-output after processing a markdown file to .tex --> .pdf
It adds the word "stylecolors" in the .pdf file
Why is it doing that?
Possibly because there was a bug in the version of the filter module (2011.12.17) that you are using.
Actually, the reason is that now the filter module uses \use<namespace>styleandcolor to set style and color: \getvalue{use#1styleandcolor}{#2}{#3} Since \use<...>styleandcolor was introduced after 2011.05.18, the \getvalue evaluates to \relax, and you see "stylecolor" (the value of #2 and #3) in the output. Aditya
Updating to latest beta with ./first-setup.sh did the trick, thanks a lot mvh Janneman 22 feb 2012 kl. 18:15 skrev Aditya Mahajan:
On Wed, 22 Feb 2012, Aditya Mahajan wrote:
On Wed, 22 Feb 2012, Jan-Erik Hägglöf wrote:
Having an issue in my pdf-output after processing a markdown file to .tex --> .pdf It adds the word "stylecolors" in the .pdf file Why is it doing that?
Possibly because there was a bug in the version of the filter module (2011.12.17) that you are using.
Actually, the reason is that now the filter module uses \use<namespace>styleandcolor to set style and color:
\getvalue{use#1styleandcolor}{#2}{#3}
Since \use<...>styleandcolor was introduced after 2011.05.18, the \getvalue evaluates to \relax, and you see "stylecolor" (the value of #2 and #3) in the output.
Aditya___________________________________________________________________________________ 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 ___________________________________________________________________________________
participants (5)
-
Aditya Mahajan
-
Hans Hagen
-
Jan-Erik Hägglöf
-
Marco
-
Procházka Lukáš Ing. - Pontex s. r. o.