On 4/10/2013 4:22 PM, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
Hello,
I need to identify number of pages by Lua of an image which is to be
inserted.
The image can be of all various types supported by Ctx - e.g. .png, .pdf.
I've been using the following code so far (based on a mailing thread in
the past):
----
function nOfPages(fn)
local fig = figures.push{name = fn}
local info = figures.identify()
figures.check()
local n = fig.used.pages
inspect(fig)
figures.pop()
return n
end
----
But the code above break Ctx in the case that the image doesn't exist.
I'd need to modify the solution somehow so to return 'nil' or 'false'
(or a error message) in the case the file was not found.
How to do it?
there's a status table in fig
Hans
-----------------------------------------------------------------
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
___________________________________________________________________________________