ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Figures and Lua (continuing "Number of pages by Lua of a figure to be inserted?" somehow)
@ 2013-04-12 12:47 Procházka Lukáš Ing. - Pontex s. r. o.
  2013-04-15 15:21 ` Aditya Mahajan
  0 siblings, 1 reply; 2+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2013-04-12 12:47 UTC (permalink / raw)
  To: ConTeXt

[-- Attachment #1: Type: text/plain, Size: 1689 bytes --]

Hello,

I tried to make a "more minimal" example.

Still we have:

files:

./t3.mkiv
./T/Kn.pdf

and code:

----
\startluacode
   test = function(fn)
     local fig = figures.push{name = fn}
       if figures.identify().status.status ~= 0 then
         figures.check()
       end
     figures.pop()

     return fn .. ": " .. (fig.used.pages or "?") .. "\\par"
   end
\stopluacode

\starttext
   AAA

   \startluacode
     context(test("T/Kn.pdf")) -- Found - OK
     context(test("Kn.pdf")) -- Not found - OK
   \stopluacode

   \setupexternalfigures[directory=T]

   \startluacode
     context(test("Kn.pdf")) -- Not found (or unknown number of pages) - UNEXPECTED - why? ("3rd call")
   \stopluacode

   \externalfigure[Kn.pdf][scale=625] % Found - OK
\stoptext
----

The 3rd call of 'test()' seems to not locate 'Kn.pdf' although the path was altered by preceding \setupexternalfigures.

How to modify the 'test()' to work properly even in the 3rd case?

NB:
Sorry for repeating the topic "in another coat" - it may not be so interesting for listeners of this mailing list.
But the goal is to add figures and PDF files into the document automatically.
One of the tasks is to detect number of pages of the figure.
The code above is a core cut out; it should work (or: if this part wouldn't work, neither would the rest) even in the 3rd case.

Any help to make the piece of code work would be appreciated.

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: t3.zip --]
[-- Type: application/zip, Size: 20306 bytes --]

[-- Attachment #3: t3.mkiv --]
[-- Type: application/octet-stream, Size: 620 bytes --]

\startluacode
  test = function(fn)
    local fig = figures.push{name = fn}
      if figures.identify().status.status ~= 0 then
        figures.check()
      end
    figures.pop()

    return fn .. ": " .. (fig.used.pages or "?") .. "\\par"
  end
\stopluacode

\starttext
  AAA

  \startluacode
    context(test("T/Kn.pdf")) -- Found - OK
    context(test("Kn.pdf")) -- Not found - OK
  \stopluacode

  \setupexternalfigures[directory=T]

  \startluacode
    context(test("Kn.pdf")) -- Not found - UNEXPECTED - why?
  \stopluacode

  \externalfigure[Kn.pdf][scale=625] % Found - OK
\stoptext

[-- Attachment #4: t3.pdf --]
[-- Type: application/pdf, Size: 12686 bytes --]

[-- Attachment #5: Kn.pdf --]
[-- Type: application/pdf, Size: 17996 bytes --]

[-- Attachment #6: 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Figures and Lua (continuing "Number of pages by Lua of a figure to be inserted?" somehow)
  2013-04-12 12:47 Figures and Lua (continuing "Number of pages by Lua of a figure to be inserted?" somehow) Procházka Lukáš Ing. - Pontex s. r. o.
@ 2013-04-15 15:21 ` Aditya Mahajan
  0 siblings, 0 replies; 2+ messages in thread
From: Aditya Mahajan @ 2013-04-15 15:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1229 bytes --]

On Fri, 12 Apr 2013, Procházka Lukáš Ing. - Pontex s. r. o. wrote:

> Hello,
>
> I tried to make a "more minimal" example.
>
> Still we have:
>
> files:
>
> ./t3.mkiv
> ./T/Kn.pdf
>
> and code:
>
> ----
> \startluacode
> test = function(fn)
>   local fig = figures.push{name = fn}
>     if figures.identify().status.status ~= 0 then
>       figures.check()
>     end
>   figures.pop()
>
>   return fn .. ": " .. (fig.used.pages or "?") .. "\\par"
> end
> \stopluacode
>
> \starttext
> AAA
>
> \startluacode
>   context(test("T/Kn.pdf")) -- Found - OK
>   context(test("Kn.pdf")) -- Not found - OK
> \stopluacode
>
> \setupexternalfigures[directory=T]
>
> \startluacode
>   context(test("Kn.pdf")) -- Not found (or unknown number of pages) - 
> UNEXPECTED - why? ("3rd call")
> \stopluacode
>
> \externalfigure[Kn.pdf][scale=625] % Found - OK
> \stoptext
> ----
>
> The 3rd call of 'test()' seems to not locate 'Kn.pdf' although the path was 
> altered by preceding \setupexternalfigures.
>
> How to modify the 'test()' to work properly even in the 3rd case?

Look at figres.setpath() in grph-inc.lua and search figures.paths and 
figures_paths to see how it is used.

Aditya

[-- Attachment #2: 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-15 15:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-12 12:47 Figures and Lua (continuing "Number of pages by Lua of a figure to be inserted?" somehow) Procházka Lukáš Ing. - Pontex s. r. o.
2013-04-15 15:21 ` Aditya Mahajan

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).