ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Clipping multiple PDFs
@ 2022-08-18  0:13 jethro Reuel via ntg-context
  2022-08-21 16:41 ` Pablo Rodriguez via ntg-context
  0 siblings, 1 reply; 11+ messages in thread
From: jethro Reuel via ntg-context @ 2022-08-18  0:13 UTC (permalink / raw)
  To: ntg-context; +Cc: jethro Reuel

Hello,

I am trying to put multiple PDF’s that were typeset differently into one document without modifying the individual files themselves. I came up with this:

\starttext

\copypages[ass1.pdf][][scale=950]
\copypages[ass2.pdf][][scale=950]
…

stoptext

The problem is the original page numbers show and I’d prefer that it did not. So I thought maybe I could clip all the page numbers from every page (since they are all in the same position across all the pages) but I don’t know how to do this with the \clip command. Any ideas? I already tried using \input but it gives some weird output in some places. It doesn’t have to use this method as long as it does what I need it to do.

Thanks in advance.

Jethro 

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Clipping multiple PDFs
  2022-08-18  0:13 Clipping multiple PDFs jethro Reuel via ntg-context
@ 2022-08-21 16:41 ` Pablo Rodriguez via ntg-context
  2022-08-22 15:46   ` Jethro Djan via ntg-context
  0 siblings, 1 reply; 11+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-08-21 16:41 UTC (permalink / raw)
  To: jethro Reuel via ntg-context; +Cc: Pablo Rodriguez

On 8/18/22 02:13, jethro Reuel via ntg-context wrote:
> Hello,
>
> I am trying to put multiple PDF’s that were typeset differently into
> one document without modifying the individual files themselves.
> [...]
> The problem is the original page numbers show and I’d prefer that it
> did not. So I thought maybe I could clip all the page numbers from
> every page (since they are all in the same position across all the
> pages) but I don’t know how to do this with the \clip command. Any
> ideas? I already tried using \input but it gives some weird output in
> some places. It doesn’t have to use this method as long as it does
> what I need it to do.

Hi Jethro,

it works using \clip with \externalfigure inside a loop (\dorecurse).

With \getfiguredimensions you get the number of pages of each PDF
document (\noffigurepages).

The following source both generates the source PDF document and the
imposed result with clipped pages (just to see a sample of the commands
mentioned above):

  \startbuffer[newbuff]
  \setuppapersize[A3]
  \setupbodyfont[sans, 1200pt]
  \starttext
  \dorecurse{8}
  {\startmakeup[page][pagestate=start, align=center, style=\bf]
    \recurselevel
   \stopmakeup}
  \stoptext
  \stopbuffer
  \startmode[*first]
  \savebuffer[newbuff][source_page.tex, prefix=no]
  \executesystemcommand{context --purgeall source_page.tex}
  \stopmode
  \setuplayout[page]
  \setuppapersize[A6][A4]
  \setuppaper[nx=2, ny=2]
  \setuparranging [XY]
  \starttext
  \startnotmode[*first]
  \def\Doc{source_page.pdf}
  \getfiguredimensions[\Doc]
  \dorecurse{\noffigurepages}
    {\clip[hoffset=96mm, voffset=136mm, width=105mm, height=148mm]
        {\externalfigure[\Doc][page=\recurselevel]}}
  \stopnotmode
  \stoptext

Just in case it might help,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Clipping multiple PDFs
  2022-08-21 16:41 ` Pablo Rodriguez via ntg-context
@ 2022-08-22 15:46   ` Jethro Djan via ntg-context
  2022-08-23 15:57     ` Pablo Rodriguez via ntg-context
  0 siblings, 1 reply; 11+ messages in thread
From: Jethro Djan via ntg-context @ 2022-08-22 15:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Jethro Djan


[-- Attachment #1.1: Type: text/plain, Size: 3468 bytes --]

Thanks for the solution Pablo. It works well.

I wanted to add more pdfs (which also has many pages) and found it was
easier for me to reason in the lua side of things. This is what I have
at the moment:

\starttext
\startluacode
  local function doc(fil)
    return fil..[[.pdf]]
  end

  local function disppdf(fname)
    n = 1
    repeat
      context.externalfigure({fname},{
        page = n,
        width = "200mm",
        scale = "950"
      })
      n = n + 1
    until n == context(context.noffigurepages)
  end

  local pdffiles = {"ass1", "ass2", "ass3", "ass4", "ass5", "ass6", "ass7",
"ass8"}
  for index=1,#pdffiles do
    local f = doc(pdffiles[index])
    context.getfiguredimensions({f})
    disppdf(pdffiles[index])
  end
\stopluacode
\stoptext

I didn’t know how to get an array (or indexed table or whatever you call
it) in ConTeXt/Tex. My problem is now with context(context.noffigurepages).
Am I calling it wrong? All I want to do is call \noffigurepages from the
lua side. Is there something I am missing?

Jethro

On 21 Aug 2022, at 4:41 PM, Pablo Rodriguez via ntg-context <
ntg-context@ntg.nl> wrote:

On 8/18/22 02:13, jethro Reuel via ntg-context wrote:

Hello,

I am trying to put multiple PDF’s that were typeset differently into
one document without modifying the individual files themselves.
[...]
The problem is the original page numbers show and I’d prefer that it
did not. So I thought maybe I could clip all the page numbers from
every page (since they are all in the same position across all the
pages) but I don’t know how to do this with the \clip command. Any
ideas? I already tried using \input but it gives some weird output in
some places. It doesn’t have to use this method as long as it does
what I need it to do.


Hi Jethro,

it works using \clip with \externalfigure inside a loop (\dorecurse).

With \getfiguredimensions you get the number of pages of each PDF
document (\noffigurepages).

The following source both generates the source PDF document and the
imposed result with clipped pages (just to see a sample of the commands
mentioned above):

 \startbuffer[newbuff]
 \setuppapersize[A3]
 \setupbodyfont[sans, 1200pt]
 \starttext
 \dorecurse{8}
 {\startmakeup[page][pagestate=start, align=center, style=\bf]
   \recurselevel
  \stopmakeup}
 \stoptext
 \stopbuffer
 \startmode[*first]
 \savebuffer[newbuff][source_page.tex, prefix=no]
 \executesystemcommand{context --purgeall source_page.tex}
 \stopmode
 \setuplayout[page]
 \setuppapersize[A6][A4]
 \setuppaper[nx=2, ny=2]
 \setuparranging [XY]
 \starttext
 \startnotmode[*first]
 \def\Doc{source_page.pdf}
 \getfiguredimensions[\Doc]
 \dorecurse{\noffigurepages}
   {\clip[hoffset=96mm, voffset=136mm, width=105mm, height=148mm]
       {\externalfigure[\Doc][page=\recurselevel]}}
 \stopnotmode
 \stoptext

Just in case it might help,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to
the Wiki!

maillist : ntg-context@ntg.nl /
https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

[-- Attachment #1.2: Type: text/html, Size: 4766 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Clipping multiple PDFs
  2022-08-22 15:46   ` Jethro Djan via ntg-context
@ 2022-08-23 15:57     ` Pablo Rodriguez via ntg-context
  2022-08-23 17:12       ` Jethro Djan via ntg-context
  0 siblings, 1 reply; 11+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-08-23 15:57 UTC (permalink / raw)
  To: Jethro Djan via ntg-context; +Cc: Pablo Rodriguez

On 8/22/22 17:46, Jethro Djan via ntg-context wrote:
> Thanks for the solution Pablo. It works well.

Glad to read it worked for you, Jethro.

> I wanted to add more pdfs (which also has many pages) and found it
> was easier for me to reason in the lua side of things. This is what I
> have at the moment:

I think this might be what you intend:

  \setuplayout[page]
  \starttext
  \doloopoverlist{ass1,ass2,ass3,ass4,ass5,ass6,ass7,ass8}
    {\def\Doc{\recursestring.pdf}
     \getfiguredimensions[\Doc]
     \dorecurse{\noffigurepages}
     {\externalfigure[\Doc]
       [page=\recurselevel, width=20cm, scale=950]}}
  \stoptext

> I didn’t know how to get an array (or indexed table or whatever you
> call it) in ConTeXt/Tex.

\doloopoverlist & \recursestring are your friends here.

> My problem is now with context(context.noffigurepages). Am I calling
> it wrong? All I want to do is call \noffigurepages from the lua side.
> Is there something I am missing?

The approach is totally different: "getnofpages"
(http://www.pragma-ade.com/general/manuals/luametatex.pdf#search=getnofpages).

BTW, your code crashed my session, CPU goes to 100% and RAM usage too. I
wonder how your sample could be compiled fine by your system.

I hope it helps,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Clipping multiple PDFs
  2022-08-23 15:57     ` Pablo Rodriguez via ntg-context
@ 2022-08-23 17:12       ` Jethro Djan via ntg-context
  2022-08-23 17:50         ` Pablo Rodriguez via ntg-context
  0 siblings, 1 reply; 11+ messages in thread
From: Jethro Djan via ntg-context @ 2022-08-23 17:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Jethro Djan


[-- Attachment #1.1: Type: text/plain, Size: 2549 bytes --]

Hello,

Thanks to Pablo and Aditya for the solutions. Sometimes it is very
difficult to find the right manuals and info for what you want to achieve
for those of us new to ConTeXt. I found the stuff on
context(context.noffigurepages) here (
https://wiki.contextgarden.net/Image_Placement) and I didn’t know the
manual you linked to existed. I have also been searching for stuff about
“low-level” stuff in ConTexT like the \doloopoverlist command.

I hope to contribute to the online wiki as I become a better user of
ConTeXt.

On Tue, Aug 23, 2022 at 3:58 PM Pablo Rodriguez via ntg-context <
ntg-context@ntg.nl> wrote:

> On 8/22/22 17:46, Jethro Djan via ntg-context wrote:
> > Thanks for the solution Pablo. It works well.
>
> Glad to read it worked for you, Jethro.
>
> > I wanted to add more pdfs (which also has many pages) and found it
> > was easier for me to reason in the lua side of things. This is what I
> > have at the moment:
>
> I think this might be what you intend:
>
>   \setuplayout[page]
>   \starttext
>   \doloopoverlist{ass1,ass2,ass3,ass4,ass5,ass6,ass7,ass8}
>     {\def\Doc{\recursestring.pdf}
>      \getfiguredimensions[\Doc]
>      \dorecurse{\noffigurepages}
>      {\externalfigure[\Doc]
>        [page=\recurselevel, width=20cm, scale=950]}}
>   \stoptext
>
> > I didn’t know how to get an array (or indexed table or whatever you
> > call it) in ConTeXt/Tex.
>
> \doloopoverlist & \recursestring are your friends here.
>
> > My problem is now with context(context.noffigurepages). Am I calling
> > it wrong? All I want to do is call \noffigurepages from the lua side.
> > Is there something I am missing?
>
> The approach is totally different: "getnofpages"
> (
> http://www.pragma-ade.com/general/manuals/luametatex.pdf#search=getnofpages
> ).
>
> BTW, your code crashed my session, CPU goes to 100% and RAM usage too. I
> wonder how your sample could be compiled fine by your system.
>
> I hope it helps,
>
> Pablo
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : https://contextgarden.net
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 3664 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Clipping multiple PDFs
  2022-08-23 17:12       ` Jethro Djan via ntg-context
@ 2022-08-23 17:50         ` Pablo Rodriguez via ntg-context
  0 siblings, 0 replies; 11+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-08-23 17:50 UTC (permalink / raw)
  To: Jethro Djan via ntg-context; +Cc: Pablo Rodriguez

On 8/23/22 19:12, Jethro Djan via ntg-context wrote:
> Hello,
>
> [...] I have also been searching for stuff about “low-level” stuff in
> ConTexT like the \doloopoverlist command.
https://wiki.contextgarden.net/System_Macros/Loops_and_Recursion should
contain \doloopoverlist.

I have just added
https://wiki.contextgarden.net/System_Macros/Loops_and_Recursion#\doloopoverlist.

Jethro, would you be so kind to edit it, so it may help other newcomers?

Many thanks for your help,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Clipping multiple PDFs
  2022-08-23 17:38   ` Pablo Rodriguez via ntg-context
@ 2022-08-23 17:47     ` Aditya Mahajan via ntg-context
  0 siblings, 0 replies; 11+ messages in thread
From: Aditya Mahajan via ntg-context @ 2022-08-23 17:47 UTC (permalink / raw)
  To: Pablo Rodriguez via ntg-context; +Cc: Aditya Mahajan

On Tue, 23 Aug 2022, Pablo Rodriguez via ntg-context wrote:

> On 8/23/22 17:27, Aditya Mahajan via ntg-context wrote:
> > [...]
> > For a more low-level interface to finding the number of pages, see:
> >
> > https://adityam.github.io/context-blog/post/include-multi-page-pdf/
> 
> Hi Aditya,
> 
> I wonder whether your final definition should be rewritten as:
> 
>  \unexpanded\def\includePDF[#1]%
>     {\getfiguredimensions[#1]
>      \dorecurse{\noffigurepages}
>         {\startTEXpage
>             \externalfigure[#1][page=\recurselevel]
>          \stopTEXpage}}
> 
> At least, otherwise it will only work with "talk.pdf".
> 
> Or am I missing something?

Thanks. That was a typo and is now fixed.

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Clipping multiple PDFs
  2022-08-23 15:27 ` Aditya Mahajan via ntg-context
@ 2022-08-23 17:38   ` Pablo Rodriguez via ntg-context
  2022-08-23 17:47     ` Aditya Mahajan via ntg-context
  0 siblings, 1 reply; 11+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-08-23 17:38 UTC (permalink / raw)
  To: Aditya Mahajan via ntg-context; +Cc: Pablo Rodriguez

On 8/23/22 17:27, Aditya Mahajan via ntg-context wrote:
> [...]
> For a more low-level interface to finding the number of pages, see:
>
> https://adityam.github.io/context-blog/post/include-multi-page-pdf/

Hi Aditya,

I wonder whether your final definition should be rewritten as:

 \unexpanded\def\includePDF[#1]%
    {\getfiguredimensions[#1]
     \dorecurse{\noffigurepages}
        {\startTEXpage
            \externalfigure[#1][page=\recurselevel]
         \stopTEXpage}}

At least, otherwise it will only work with "talk.pdf".

Or am I missing something?

Many thanks for your comment,

Pablo
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Clipping multiple PDFs
  2022-08-22 15:43 Jethro Djan via ntg-context
@ 2022-08-23 15:27 ` Aditya Mahajan via ntg-context
  2022-08-23 17:38   ` Pablo Rodriguez via ntg-context
  0 siblings, 1 reply; 11+ messages in thread
From: Aditya Mahajan via ntg-context @ 2022-08-23 15:27 UTC (permalink / raw)
  To: Jethro Djan via ntg-context; +Cc: Aditya Mahajan

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

On Mon, 22 Aug 2022, Jethro Djan via ntg-context wrote:

> 
> Thanks for the solution Pablo. It works well.
> 
> I wanted to add more pdfs (which also has many pages) and found it was easier for me to reason in the lua side of things. This is what I have at the moment:
> 
> \starttext
> \startluacode
>   local function doc(fil)
>     return fil..[[.pdf]]
>   end
> 
>   local function disppdf(fname)
>     n = 1 
>     repeat 
>       context.externalfigure({fname},{
>         page = n,
>         width = "200mm",
>         scale = "950"
>       })
>       n = n + 1
>     until n == context(context.noffigurepages)
>   end
> 
>   local pdffiles = {"ass1", "ass2", "ass3", "ass4", "ass5", "ass6", "ass7", "ass8"}
>   for index=1,#pdffiles do 
>     local f = doc(pdffiles[index])
>     context.getfiguredimensions({f})
>     disppdf(pdffiles[index])
>   end
> \stopluacode
> \stoptext
> 
> I didn’t know how to get an array (or indexed table or whatever you call it) in ConTeXt/Tex. My problem is now with context(context.noffigurepages). It doesn’t produce an integer so n is being compared to nil. Am I calling it wrong? All I want to do is call \noffigurepages from the lua side. Is there something I am missing?

For a more low-level interface to finding the number of pages, see:

https://adityam.github.io/context-blog/post/include-multi-page-pdf/

Aditya

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Clipping multiple PDFs
@ 2022-08-22 15:44 Jethro Djan via ntg-context
  0 siblings, 0 replies; 11+ messages in thread
From: Jethro Djan via ntg-context @ 2022-08-22 15:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Jethro Djan


[-- Attachment #1.1: Type: text/plain, Size: 3608 bytes --]


Thanks for the solution Pablo. It works well.

I wanted to add more pdfs (which also has many pages) and found it was easier for me to reason in the lua side of things. This is what I have at the moment:

\starttext
\startluacode
  local function doc(fil)
    return fil..[[.pdf]]
  end

  local function disppdf(fname)
    n = 1 
    repeat 
      context.externalfigure({fname},{
        page = n,
        width = "200mm",
        scale = "950"
      })
      n = n + 1
    until n == context(context.noffigurepages)
  end

  local pdffiles = {"ass1", "ass2", "ass3", "ass4", "ass5", "ass6", "ass7", "ass8"}
  for index=1,#pdffiles do 
    local f = doc(pdffiles[index])
    context.getfiguredimensions({f})
    disppdf(pdffiles[index])
  end
\stopluacode
\stoptext

I didn’t know how to get an array (or indexed table or whatever you call it) in ConTeXt/Tex. My problem is now with context(context.noffigurepages). Am I calling it wrong? All I want to do is call \noffigurepages from the lua side. Is there something I am missing?

Jethro

> On 21 Aug 2022, at 4:41 PM, Pablo Rodriguez via ntg-context <ntg-context@ntg.nl> wrote:
> 
> On 8/18/22 02:13, jethro Reuel via ntg-context wrote:
>> Hello,
>> 
>> I am trying to put multiple PDF’s that were typeset differently into
>> one document without modifying the individual files themselves.
>> [...]
>> The problem is the original page numbers show and I’d prefer that it
>> did not. So I thought maybe I could clip all the page numbers from
>> every page (since they are all in the same position across all the
>> pages) but I don’t know how to do this with the \clip command. Any
>> ideas? I already tried using \input but it gives some weird output in
>> some places. It doesn’t have to use this method as long as it does
>> what I need it to do.
> 
> Hi Jethro,
> 
> it works using \clip with \externalfigure inside a loop (\dorecurse).
> 
> With \getfiguredimensions you get the number of pages of each PDF
> document (\noffigurepages).
> 
> The following source both generates the source PDF document and the
> imposed result with clipped pages (just to see a sample of the commands
> mentioned above):
> 
>  \startbuffer[newbuff]
>  \setuppapersize[A3]
>  \setupbodyfont[sans, 1200pt]
>  \starttext
>  \dorecurse{8}
>  {\startmakeup[page][pagestate=start, align=center, style=\bf]
>    \recurselevel
>   \stopmakeup}
>  \stoptext
>  \stopbuffer
>  \startmode[*first]
>  \savebuffer[newbuff][source_page.tex, prefix=no]
>  \executesystemcommand{context --purgeall source_page.tex}
>  \stopmode
>  \setuplayout[page]
>  \setuppapersize[A6][A4]
>  \setuppaper[nx=2, ny=2]
>  \setuparranging [XY]
>  \starttext
>  \startnotmode[*first]
>  \def\Doc{source_page.pdf}
>  \getfiguredimensions[\Doc]
>  \dorecurse{\noffigurepages}
>    {\clip[hoffset=96mm, voffset=136mm, width=105mm, height=148mm]
>        {\externalfigure[\Doc][page=\recurselevel]}}
>  \stopnotmode
>  \stoptext
> 
> Just in case it might help,
> 
> Pablo
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : https://contextgarden.net
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 6232 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* Re: Clipping multiple PDFs
@ 2022-08-22 15:43 Jethro Djan via ntg-context
  2022-08-23 15:27 ` Aditya Mahajan via ntg-context
  0 siblings, 1 reply; 11+ messages in thread
From: Jethro Djan via ntg-context @ 2022-08-22 15:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Jethro Djan


[-- Attachment #1.1: Type: text/plain, Size: 3671 bytes --]


Thanks for the solution Pablo. It works well.

I wanted to add more pdfs (which also has many pages) and found it was easier for me to reason in the lua side of things. This is what I have at the moment:

\starttext
\startluacode
  local function doc(fil)
    return fil..[[.pdf]]
  end

  local function disppdf(fname)
    n = 1 
    repeat 
      context.externalfigure({fname},{
        page = n,
        width = "200mm",
        scale = "950"
      })
      n = n + 1
    until n == context(context.noffigurepages)
  end

  local pdffiles = {"ass1", "ass2", "ass3", "ass4", "ass5", "ass6", "ass7", "ass8"}
  for index=1,#pdffiles do 
    local f = doc(pdffiles[index])
    context.getfiguredimensions({f})
    disppdf(pdffiles[index])
  end
\stopluacode
\stoptext

I didn’t know how to get an array (or indexed table or whatever you call it) in ConTeXt/Tex. My problem is now with context(context.noffigurepages). It doesn’t produce an integer so n is being compared to nil. Am I calling it wrong? All I want to do is call \noffigurepages from the lua side. Is there something I am missing?

Jethro

> On 21 Aug 2022, at 4:41 PM, Pablo Rodriguez via ntg-context <ntg-context@ntg.nl> wrote:
> 
> On 8/18/22 02:13, jethro Reuel via ntg-context wrote:
>> Hello,
>> 
>> I am trying to put multiple PDF’s that were typeset differently into
>> one document without modifying the individual files themselves.
>> [...]
>> The problem is the original page numbers show and I’d prefer that it
>> did not. So I thought maybe I could clip all the page numbers from
>> every page (since they are all in the same position across all the
>> pages) but I don’t know how to do this with the \clip command. Any
>> ideas? I already tried using \input but it gives some weird output in
>> some places. It doesn’t have to use this method as long as it does
>> what I need it to do.
> 
> Hi Jethro,
> 
> it works using \clip with \externalfigure inside a loop (\dorecurse).
> 
> With \getfiguredimensions you get the number of pages of each PDF
> document (\noffigurepages).
> 
> The following source both generates the source PDF document and the
> imposed result with clipped pages (just to see a sample of the commands
> mentioned above):
> 
>  \startbuffer[newbuff]
>  \setuppapersize[A3]
>  \setupbodyfont[sans, 1200pt]
>  \starttext
>  \dorecurse{8}
>  {\startmakeup[page][pagestate=start, align=center, style=\bf]
>    \recurselevel
>   \stopmakeup}
>  \stoptext
>  \stopbuffer
>  \startmode[*first]
>  \savebuffer[newbuff][source_page.tex, prefix=no]
>  \executesystemcommand{context --purgeall source_page.tex}
>  \stopmode
>  \setuplayout[page]
>  \setuppapersize[A6][A4]
>  \setuppaper[nx=2, ny=2]
>  \setuparranging [XY]
>  \starttext
>  \startnotmode[*first]
>  \def\Doc{source_page.pdf}
>  \getfiguredimensions[\Doc]
>  \dorecurse{\noffigurepages}
>    {\clip[hoffset=96mm, voffset=136mm, width=105mm, height=148mm]
>        {\externalfigure[\Doc][page=\recurselevel]}}
>  \stopnotmode
>  \stoptext
> 
> Just in case it might help,
> 
> Pablo
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : https://contextgarden.net
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 6295 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2022-08-23 17:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18  0:13 Clipping multiple PDFs jethro Reuel via ntg-context
2022-08-21 16:41 ` Pablo Rodriguez via ntg-context
2022-08-22 15:46   ` Jethro Djan via ntg-context
2022-08-23 15:57     ` Pablo Rodriguez via ntg-context
2022-08-23 17:12       ` Jethro Djan via ntg-context
2022-08-23 17:50         ` Pablo Rodriguez via ntg-context
2022-08-22 15:43 Jethro Djan via ntg-context
2022-08-23 15:27 ` Aditya Mahajan via ntg-context
2022-08-23 17:38   ` Pablo Rodriguez via ntg-context
2022-08-23 17:47     ` Aditya Mahajan via ntg-context
2022-08-22 15:44 Jethro Djan via ntg-context

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