Merging pdf files consisting of MPpages - Can it be done?
Hi all, The following example creates a unitcircle scaled to the \recurselevel value on each MPpage. \starttext \dostepwiserecurse{1}{80}{1}{ \startMPpage path a; a := unitsquare xyscaled(80,80) ; draw a; draw unitcircle xyscaled(\recurselevel , \recurselevel); \stopMPpage } \dostepwiserecurse{79}{2}{-1}{ \startMPpage path a; a := unitsquare xyscaled(80,80) ; draw a; draw unitcircle xyscaled(\recurselevel , \recurselevel); \stopMPpage } \stoptext If you run this and scan through pages, the circle starts at 1 and increases to 80 and then decreases from 79 to 2. I use the pdf to create a mp4 movie showing the circle increasing and decreasing when I replay it as a loop. You can download the file here: https://1drv.ms/v/c/de5fffb8e01e255b/IQCLuQ9bYQovSIaOc7S5vc8_AQnAfqudRCjr_PC... However if my graphic is complicated, compilation time will increase by quite a bit. So I was thinking that when the circle is decreasing I have already calculated those MPpages as the circle was increasing so could I not reuse those MPpages to create the following sequence of MPpages? 1, 2, 3, ... 78, 79, 80, 79, 78, ...3, 2 i.e I have reused the MPpages 79 to 2 which would loop in a movie when played back. I though I could make a copy the pdf file then add MPpages from the original file to create the sequence of MPpages above. I've had a look through the merging pdf files manual and it suggests using: \externalfigure[myfile.pdf][page=4] but that doesn't seem to work with MPpages since it adds the pdf page as a text page. Any hints on how I can solve this? Best Wishes Keith
Am 31.12.2025 um 12:38 schrieb Keith McKay:
Hi all,
The following example creates a unitcircle scaled to the \recurselevel value on each MPpage.
\starttext \dostepwiserecurse{1}{80}{1}{ \startMPpage path a; a := unitsquare xyscaled(80,80) ; draw a; draw unitcircle xyscaled(\recurselevel , \recurselevel); \stopMPpage } \dostepwiserecurse{79}{2}{-1}{ \startMPpage path a; a := unitsquare xyscaled(80,80) ; draw a; draw unitcircle xyscaled(\recurselevel , \recurselevel); \stopMPpage } \stoptext
If you run this and scan through pages, the circle starts at 1 and increases to 80 and then decreases from 79 to 2. I use the pdf to create a mp4 movie showing the circle increasing and decreasing when I replay it as a loop. You can download the file here:
https://1drv.ms/v/c/de5fffb8e01e255b/ IQCLuQ9bYQovSIaOc7S5vc8_AQnAfqudRCjr_PC_pT6Rgx8?e=fuq9AS
However if my graphic is complicated, compilation time will increase by quite a bit. So I was thinking that when the circle is decreasing I have already calculated those MPpages as the circle was increasing so could I not reuse those MPpages to create the following sequence of MPpages?
1, 2, 3, ... 78, 79, 80, 79, 78, ...3, 2
i.e I have reused the MPpages 79 to 2 which would loop in a movie when played back.
\startMPinitializations picture Circle[]; \stopMPinitializations \startbuffer \startMPpage if unknown Circle[\recurselevel] : Circle[\recurselevel] := image ( draw unitsquare scaled 80 ; draw unitcircle scaled \recurselevel ; ) ; fi ; draw Circle[\recurselevel] ; \stopMPpage \stopbuffer \starttext \dostepwiserecurse{1}{80}{1}{\getbuffer} \dostepwiserecurse{79}{2}{-1}{\getbuffer} \stoptext Wolfgang
Thanks Wolfgang your solution works great! Keith On 31/12/2025 12:30, Wolfgang Schuster wrote:
Snip >
\startMPinitializations picture Circle[]; \stopMPinitializations
\startbuffer \startMPpage if unknown Circle[\recurselevel] : Circle[\recurselevel] := image ( draw unitsquare scaled 80 ; draw unitcircle scaled \recurselevel ; ) ; fi ; draw Circle[\recurselevel] ; \stopMPpage \stopbuffer
\starttext \dostepwiserecurse{1}{80}{1}{\getbuffer} \dostepwiserecurse{79}{2}{-1}{\getbuffer} \stoptext
Wolfgang
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
Am 31.12.25 um 12:38 schrieb Keith McKay:
I though I could make a copy the pdf file then add MPpages from the original file to create the sequence of MPpages above. I've had a look through the merging pdf files manual and it suggests using:
\externalfigure[myfile.pdf][page=4]
but that doesn't seem to work with MPpages since it adds the pdf page as a text page. Any hints on how I can solve this?
Did you try \copypages[myfile.pdf][n=10]%[scale=720] or \filterpages[myfile.pdf][1,3,4:8]%[scale=1210] ? I didn’t check if that adds pages. Maybe you need one document with \starttext … \stoptext and another with the TEXpages. Hraban
Thanks for suggestion Hraban. I tried both but without success, they added the pdf page as a text page. Thanks anyway Keith On 31/12/2025 12:32, Henning Hraban Ramm wrote:
Am 31.12.25 um 12:38 schrieb Keith McKay:
I though I could make a copy the pdf file then add MPpages from the original file to create the sequence of MPpages above. I've had a look through the merging pdf files manual and it suggests using:
\externalfigure[myfile.pdf][page=4]
but that doesn't seem to work with MPpages since it adds the pdf page as a text page. Any hints on how I can solve this?
Did you try \copypages[myfile.pdf][n=10]%[scale=720] or \filterpages[myfile.pdf][1,3,4:8]%[scale=1210] ?
I didn’t check if that adds pages. Maybe you need one document with \starttext … \stoptext and another with the TEXpages.
Hraban ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
On 12/31/2025 12:38 PM, Keith McKay wrote:
Hi all,
The following example creates a unitcircle scaled to the \recurselevel value on each MPpage.
\starttext \dostepwiserecurse{1}{80}{1}{ \startMPpage path a; a := unitsquare xyscaled(80,80) ; draw a; draw unitcircle xyscaled(\recurselevel , \recurselevel); \stopMPpage } \dostepwiserecurse{79}{2}{-1}{ \startMPpage path a; a := unitsquare xyscaled(80,80) ; draw a; draw unitcircle xyscaled(\recurselevel , \recurselevel); \stopMPpage } \stoptext
If you run this and scan through pages, the circle starts at 1 and increases to 80 and then decreases from 79 to 2. I use the pdf to create a mp4 movie showing the circle increasing and decreasing when I replay it as a loop. You can download the file here:
https://1drv.ms/v/c/de5fffb8e01e255b/ IQCLuQ9bYQovSIaOc7S5vc8_AQnAfqudRCjr_PC_pT6Rgx8?e=fuq9AS
However if my graphic is complicated, compilation time will increase by quite a bit. So I was thinking that when the circle is decreasing I have already calculated those MPpages as the circle was increasing so could I not reuse those MPpages to create the following sequence of MPpages?
1, 2, 3, ... 78, 79, 80, 79, 78, ...3, 2
i.e I have reused the MPpages 79 to 2 which would loop in a movie when played back.
I though I could make a copy the pdf file then add MPpages from the original file to create the sequence of MPpages above. I've had a look through the merging pdf files manual and it suggests using:
\externalfigure[myfile.pdf][page=4]
but that doesn't seem to work with MPpages since it adds the pdf page as a text page. Any hints on how I can solve this?
If it's the same graphic but just scaled, \starttext \startreusableMPgraphic{keith} draw unitcircle xyscaled(10,10); \stopreusableMPgraphic \dostepwiserecurse{1}{80}{1}{ \startTEXpage[width=80mm,height=80mm] \vfill \scale[width=#1mm]{\reuseMPgraphic{keith}} \stopTEXpage } \dostepwiserecurse{79}{2}{-1}{ \startTEXpage[width=80mm,height=80mm] \vfill \scale[width=#1mm]{\reuseMPgraphic{keith}} \stopTEXpage } \stoptext Otherwise look at the other posted solutions. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Thanks Hans that also works great. Speed wise their is not much difference between your method and Wolfgang's. It's good to have more than one solution. Thanks again Keith On 31/12/2025 12:42, Hans Hagen via ntg-context wrote:
On 12/31/2025 12:38 PM, Keith McKay wrote:
Hi all,
The following example creates a unitcircle scaled to the \recurselevel value on each MPpage.
\starttext \dostepwiserecurse{1}{80}{1}{ \startMPpage path a; a := unitsquare xyscaled(80,80) ; draw a; draw unitcircle xyscaled(\recurselevel , \recurselevel); \stopMPpage } \dostepwiserecurse{79}{2}{-1}{ \startMPpage path a; a := unitsquare xyscaled(80,80) ; draw a; draw unitcircle xyscaled(\recurselevel , \recurselevel); \stopMPpage } \stoptext
If you run this and scan through pages, the circle starts at 1 and increases to 80 and then decreases from 79 to 2. I use the pdf to create a mp4 movie showing the circle increasing and decreasing when I replay it as a loop. You can download the file here:
https://1drv.ms/v/c/de5fffb8e01e255b/ IQCLuQ9bYQovSIaOc7S5vc8_AQnAfqudRCjr_PC_pT6Rgx8?e=fuq9AS
However if my graphic is complicated, compilation time will increase by quite a bit. So I was thinking that when the circle is decreasing I have already calculated those MPpages as the circle was increasing so could I not reuse those MPpages to create the following sequence of MPpages?
1, 2, 3, ... 78, 79, 80, 79, 78, ...3, 2
i.e I have reused the MPpages 79 to 2 which would loop in a movie when played back.
I though I could make a copy the pdf file then add MPpages from the original file to create the sequence of MPpages above. I've had a look through the merging pdf files manual and it suggests using:
\externalfigure[myfile.pdf][page=4]
but that doesn't seem to work with MPpages since it adds the pdf page as a text page. Any hints on how I can solve this?
If it's the same graphic but just scaled,
\starttext \startreusableMPgraphic{keith} draw unitcircle xyscaled(10,10); \stopreusableMPgraphic \dostepwiserecurse{1}{80}{1}{ \startTEXpage[width=80mm,height=80mm] \vfill \scale[width=#1mm]{\reuseMPgraphic{keith}} \stopTEXpage } \dostepwiserecurse{79}{2}{-1}{ \startTEXpage[width=80mm,height=80mm] \vfill \scale[width=#1mm]{\reuseMPgraphic{keith}} \stopTEXpage } \stoptext
Otherwise look at the other posted solutions.
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | 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 / https://mailman.ntg.nl/mailman3/lists/ ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
participants (4)
-
Hans Hagen -
Henning Hraban Ramm -
Keith McKay -
Wolfgang Schuster