From: "Procházka Lukáš Ing. - Pontex s. r. o." <LPr@pontex.cz>
To: ConTeXt <ntg-context@ntg.nl>
Subject: Re: Number of pages by Lua of a figure to be inserted?
Date: Thu, 11 Apr 2013 09:10:28 +0200 [thread overview]
Message-ID: <op.wvc7jqo5tpjj8f@lpr> (raw)
In-Reply-To: <51658779.2060402@wxs.nl>
[-- Attachment #1: Type: text/plain, Size: 1941 bytes --]
Hello,
thanks for the hint.
Could you please check my code?
The function is able to detect number of pages (tested with a .pdf, which works; I believe it will work with other figure formats, too).
When the file is not found, it doesn't break Ctx, which is good.
The problem is that once a file is not found, later calls to the function fail (means they return 'false'), too.
It seems like a figure being "hanging" somewhere or what; but I'm not able to find the bad place iin the code.
Note that the directory structure is:
t2.mkiv - file to be tested
T/Kn.pdf - file to be inserted (2 pages)
---- t2.mkiv
\startluacode
nOfPages = function(fn)
local n
do
local fig = figures.push{name = fn}
local info = figures.identify()
--inspect(info)
if info.status.status ~= 0 then
figures.check() -- This may check all figures; I'm interested in the last figure only - any call improvement?
n = fig.used.pages
end
figures.pop() -- I thought no figure should stay "hanging" due to this line
end
if not n then return false end
return n
end
\stopluacode
\starttext
AAA
\startluacode
context(nOfPages("Kn.pdf") or "???") -- [1]
-- When you comment the line above, later Ctx detects correctly 2 pages of 'Kn.pdf'.
\stopluacode
\setupexternalfigures[directory=T] % Find the 'Kn.pdf' in 'T/Kn.pdf'
\startluacode
context(nOfPages("Kn.pdf") or "???")
-- Now, Ctx should find 'T/Kn.pdf' anyway and thus detect 2 pages of 'Kn.pdf'.
-- This doesn't occure when [1] is on
\stopluacode
\stoptext
----
Any idea?
TIA.
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
[-- Attachment #2: t2.zip --]
[-- Type: application/zip, Size: 12850 bytes --]
[-- Attachment #3: Type: text/plain, Size: 485 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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
prev parent reply other threads:[~2013-04-11 7:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 14:22 Procházka Lukáš Ing. - Pontex s. r. o.
2013-04-10 15:38 ` Hans Hagen
2013-04-11 7:10 ` Procházka Lukáš Ing. - Pontex s. r. o. [this message]
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=op.wvc7jqo5tpjj8f@lpr \
--to=lpr@pontex.cz \
--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).