6

I want to make a document which consists of, let's say, one page, which has to be repeated 10000 times. On each repetition of a page a unique number will be added on the page (I won't show it in MWE, because it is not my question).

So, there are two ways I see: make a command \makepage that will produce a page and then do

\foreach\AA in{1,...,10000}{
    \makepage
    \newpage
}

or make one-paged pdf and then

\foreach\AA in{1,...,10000}{
    \includepdf{page.pdf}
}

Of course, the second was faster (451 vs 279 sec), but the time is not of concern. I want to reduce the size of pdf (the second is smaller: 32356 KB vs 1905 KB -- big difference), also I would like not to run into Tex capacity exceeded.

The question is: can I make this process even more effective in terms of size? NOTE: I must use LuaLaTeX.

UPDATE: the first method (with replicating the same page many times) produced 50000 pages without crashing, while the second method crashed on 15000 page with Tex capcity exceeded

The MWE

page.tex with a big heavy picture and Debian logo

\documentclass{article}

\usepackage{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\usepackage{mathtools}
\usetikzlibrary{shapes,calc}
\usepackage{ifpdf}

\geometry{margin=0.5cm}

\setlength{\parindent}{0pt}
    \definecolor{cd60952}{RGB}{214,9,82}
\newcommand{\makepage}{
    \includegraphics[width=\textwidth]{1200.jpg}
    \lipsum[1]

    \resizebox{\textwidth}{8cm}{
    \begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1, inner sep=0pt, outer sep=0pt]
    \path[fill=cd60952] (93.3195,230.9447) .. controls (59.0303,225.9343) and
      (31.1801,199.9495) .. (15.3715,170.2215) .. controls (5.5821,151.9201) and
      (1.0492,131.0592) .. (2.0713,110.3467) .. controls (2.9610,99.6354) and
      (-0.0316,88.4491) .. (3.6168,78.1309) .. controls (6.5315,67.3276) and
      (11.4331,57.5607) .. (18.0741,49.0323) .. controls (22.8424,36.3018) and
      (33.0142,26.6294) .. (43.3849,18.3207) .. controls (51.2637,15.0948) and
      (58.7196,8.4670) .. (67.3399,5.6708) .. controls (73.0270,2.1030) and
      (86.2192,-0.8740) .. (89.3376,0.7517) .. controls (87.1714,3.1299) and
      (96.8246,1.5167) .. (97.2769,4.1226) .. controls (107.4188,3.5384) and
      (115.9073,1.2904) .. (125.1827,6.6191) .. controls (130.1554,7.5866) and
      (134.4480,12.7054) .. (139.6428,10.2061) .. controls (146.0329,9.0034) and
      (150.3844,18.7601) .. (153.4049,15.9781) .. controls (167.0146,25.0067) and
      (179.0895,38.0628) .. (183.8766,53.8550) .. controls (180.8933,56.9429) and
      (186.6577,70.4714) .. (181.7816,59.7076) .. controls (180.8871,49.0368) and
      (168.0386,56.5647) .. (177.2058,61.0368) .. controls (179.2498,65.0404) and
      (182.0841,75.4132) .. (177.7802,71.7036) .. controls (180.1689,78.0221) and
      (180.9576,84.7644) .. (181.6522,89.9051) .. controls (179.1588,98.4216) and
      (176.1557,101.9826) .. (173.6042,111.8841) .. controls (170.9595,115.2866) and
      (171.0389,123.7597) .. (166.8992,120.5686) .. controls (165.2312,131.1547) and
      (155.5965,133.9765) .. (147.0796,141.2926) .. controls (132.2241,150.3707) and
      (112.9512,151.3272) .. (97.0139,144.6226) .. controls (84.6896,134.9490) and
      (70.7373,122.6945) .. (71.4998,105.4775) .. controls (70.3035,95.6431) and
      (74.2758,85.9523) .. (80.1058,78.2380) .. controls (88.0500,64.3879) and
      (106.9185,57.9312) .. (121.3004,65.4772) .. controls (125.4446,66.6683) and
      (135.3869,75.8586) .. (125.6405,70.0166) .. controls (107.1390,60.8500) and
      (82.4175,73.0004) .. (78.4654,93.3286) .. controls (76.0174,103.5799) and
      (80.0184,114.3881) .. (84.8167,123.4648) .. controls (93.9795,138.1966) and
      (113.4423,146.7081) .. (130.0863,140.0509) .. controls (139.2098,136.5960) and
      (146.4827,132.8242) .. (153.8322,125.8050) .. controls (158.6678,121.0523) and
      (159.0520,114.5674) .. (163.7343,109.5653) .. controls (167.1049,100.0360) and
      (164.7856,89.6203) .. (165.4952,79.5371) .. controls (164.0280,57.0736) and
      (149.4942,35.8534) .. (129.2629,26.0379) .. controls (115.1366,19.7678) and
      (99.0343,20.6064) .. (84.0979,22.4500) .. controls (80.5464,24.0798) and
      (67.4651,29.1244) .. (69.5458,30.0952) .. controls (72.5853,31.9093) and
      (56.7456,31.7609) .. (54.7847,36.8147) .. controls (50.3008,39.5539) and
      (57.4995,40.3709) .. (50.0780,41.5699) .. controls (38.7079,46.8575) and
      (29.9921,56.8048) .. (22.7900,66.8497) .. controls (24.2223,74.7738) and
      (14.2196,82.5255) .. (15.2267,91.6025) .. controls (14.1505,104.8645) and
      (11.1105,118.9822) .. (16.2776,131.6949) .. controls (15.8162,141.4332) and
      (19.5505,151.1444) .. (28.7610,155.2116) .. controls (30.8205,158.2024) and
      (33.8190,164.2180) .. (28.6238,161.1753) .. controls (32.7528,168.8945) and
      (34.4245,176.2610) .. (38.7270,183.6412) .. controls (45.0741,189.2992) and
      (47.5361,199.7078) .. (55.4974,202.5513) .. controls (63.5448,208.0481) and
      (63.3757,214.0812) .. (72.5802,217.5521) .. controls (79.7480,217.8771) and
      (85.3707,228.8788) .. (94.9911,228.7819) .. controls (100.7223,229.5682) and
      (108.6001,231.6152) .. (98.2271,231.1305) .. controls (96.5907,231.1102) and
      (94.9496,231.1072) .. (93.3195,230.9447) -- cycle(109.3652,153.7333) ..
      controls (96.4622,150.5469) and (82.9305,143.6407) .. (76.0433,131.9692) ..
      controls (79.5521,134.7556) and (88.1011,145.5911) .. (85.2368,139.0080) ..
      controls (93.3693,144.5154) and (101.6217,150.7951) .. (111.5236,152.3574) ..
      controls (116.2089,152.7513) and (130.2176,153.5790) .. (117.6684,154.3630) ..
      controls (114.8884,154.4545) and (112.0843,154.3802) .. (109.3652,153.7333) --
      cycle(74.3902,136.2898) .. controls (70.9933,133.9581) and (67.6115,123.2929)
      .. (72.5676,131.3425) .. controls (72.9289,132.3219) and (79.0347,140.7760) ..
      (74.3902,136.2898) -- cycle(75.3359,126.6654) .. controls (74.7471,124.0079)
      and (76.8271,128.4288) .. (75.3359,126.6654) -- cycle(113.5388,123.1048) ..
      controls (105.3566,120.3225) and (128.7758,120.8069) .. (116.9857,123.7831) --
      (115.4446,123.6429) -- (113.5388,123.1048) -- (113.5388,123.1048) --
      cycle(132.1116,115.1364) .. controls (132.2953,111.7123) and
      (137.6293,113.8487) .. (132.1116,115.1364) -- cycle(139.1412,95.2606) ..
      controls (137.7252,89.2646) and (142.7469,94.5535) .. (139.6272,96.2902) --
      (139.1412,95.2606) -- cycle(0.0872,71.0995) .. controls (-0.2143,65.5523) and
      (4.4217,66.0913) .. (0.0872,71.0995) -- cycle(5.9486,51.8358) .. controls
      (8.5268,42.0593) and (8.4517,55.9487) .. (5.9486,51.8358) --
      cycle(101.3758,1.5022) .. controls (104.1751,0.8687) and (101.0824,2.7449) ..
      (101.3758,1.5022) -- cycle;

    \end{tikzpicture}
    }
}

\begin{document}

    \makepage

\end{document}

manypages.tex with the first method

\documentclass{article}

\usepackage{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\usepackage{mathtools}
\usetikzlibrary{shapes,calc}
\usepackage{ifpdf}

\geometry{margin=0.5cm}

\setlength{\parindent}{0pt}
    \definecolor{cd60952}{RGB}{214,9,82}
\newcommand{\makepage}{
    \includegraphics[width=\textwidth]{1200.jpg}
    \lipsum[1]

    \resizebox{\textwidth}{8cm}{
    \begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1, inner sep=0pt, outer sep=0pt]
    \path[fill=cd60952] (93.3195,230.9447) .. controls (59.0303,225.9343) and
      (31.1801,199.9495) .. (15.3715,170.2215) .. controls (5.5821,151.9201) and
      (1.0492,131.0592) .. (2.0713,110.3467) .. controls (2.9610,99.6354) and
      (-0.0316,88.4491) .. (3.6168,78.1309) .. controls (6.5315,67.3276) and
      (11.4331,57.5607) .. (18.0741,49.0323) .. controls (22.8424,36.3018) and
      (33.0142,26.6294) .. (43.3849,18.3207) .. controls (51.2637,15.0948) and
      (58.7196,8.4670) .. (67.3399,5.6708) .. controls (73.0270,2.1030) and
      (86.2192,-0.8740) .. (89.3376,0.7517) .. controls (87.1714,3.1299) and
      (96.8246,1.5167) .. (97.2769,4.1226) .. controls (107.4188,3.5384) and
      (115.9073,1.2904) .. (125.1827,6.6191) .. controls (130.1554,7.5866) and
      (134.4480,12.7054) .. (139.6428,10.2061) .. controls (146.0329,9.0034) and
      (150.3844,18.7601) .. (153.4049,15.9781) .. controls (167.0146,25.0067) and
      (179.0895,38.0628) .. (183.8766,53.8550) .. controls (180.8933,56.9429) and
      (186.6577,70.4714) .. (181.7816,59.7076) .. controls (180.8871,49.0368) and
      (168.0386,56.5647) .. (177.2058,61.0368) .. controls (179.2498,65.0404) and
      (182.0841,75.4132) .. (177.7802,71.7036) .. controls (180.1689,78.0221) and
      (180.9576,84.7644) .. (181.6522,89.9051) .. controls (179.1588,98.4216) and
      (176.1557,101.9826) .. (173.6042,111.8841) .. controls (170.9595,115.2866) and
      (171.0389,123.7597) .. (166.8992,120.5686) .. controls (165.2312,131.1547) and
      (155.5965,133.9765) .. (147.0796,141.2926) .. controls (132.2241,150.3707) and
      (112.9512,151.3272) .. (97.0139,144.6226) .. controls (84.6896,134.9490) and
      (70.7373,122.6945) .. (71.4998,105.4775) .. controls (70.3035,95.6431) and
      (74.2758,85.9523) .. (80.1058,78.2380) .. controls (88.0500,64.3879) and
      (106.9185,57.9312) .. (121.3004,65.4772) .. controls (125.4446,66.6683) and
      (135.3869,75.8586) .. (125.6405,70.0166) .. controls (107.1390,60.8500) and
      (82.4175,73.0004) .. (78.4654,93.3286) .. controls (76.0174,103.5799) and
      (80.0184,114.3881) .. (84.8167,123.4648) .. controls (93.9795,138.1966) and
      (113.4423,146.7081) .. (130.0863,140.0509) .. controls (139.2098,136.5960) and
      (146.4827,132.8242) .. (153.8322,125.8050) .. controls (158.6678,121.0523) and
      (159.0520,114.5674) .. (163.7343,109.5653) .. controls (167.1049,100.0360) and
      (164.7856,89.6203) .. (165.4952,79.5371) .. controls (164.0280,57.0736) and
      (149.4942,35.8534) .. (129.2629,26.0379) .. controls (115.1366,19.7678) and
      (99.0343,20.6064) .. (84.0979,22.4500) .. controls (80.5464,24.0798) and
      (67.4651,29.1244) .. (69.5458,30.0952) .. controls (72.5853,31.9093) and
      (56.7456,31.7609) .. (54.7847,36.8147) .. controls (50.3008,39.5539) and
      (57.4995,40.3709) .. (50.0780,41.5699) .. controls (38.7079,46.8575) and
      (29.9921,56.8048) .. (22.7900,66.8497) .. controls (24.2223,74.7738) and
      (14.2196,82.5255) .. (15.2267,91.6025) .. controls (14.1505,104.8645) and
      (11.1105,118.9822) .. (16.2776,131.6949) .. controls (15.8162,141.4332) and
      (19.5505,151.1444) .. (28.7610,155.2116) .. controls (30.8205,158.2024) and
      (33.8190,164.2180) .. (28.6238,161.1753) .. controls (32.7528,168.8945) and
      (34.4245,176.2610) .. (38.7270,183.6412) .. controls (45.0741,189.2992) and
      (47.5361,199.7078) .. (55.4974,202.5513) .. controls (63.5448,208.0481) and
      (63.3757,214.0812) .. (72.5802,217.5521) .. controls (79.7480,217.8771) and
      (85.3707,228.8788) .. (94.9911,228.7819) .. controls (100.7223,229.5682) and
      (108.6001,231.6152) .. (98.2271,231.1305) .. controls (96.5907,231.1102) and
      (94.9496,231.1072) .. (93.3195,230.9447) -- cycle(109.3652,153.7333) ..
      controls (96.4622,150.5469) and (82.9305,143.6407) .. (76.0433,131.9692) ..
      controls (79.5521,134.7556) and (88.1011,145.5911) .. (85.2368,139.0080) ..
      controls (93.3693,144.5154) and (101.6217,150.7951) .. (111.5236,152.3574) ..
      controls (116.2089,152.7513) and (130.2176,153.5790) .. (117.6684,154.3630) ..
      controls (114.8884,154.4545) and (112.0843,154.3802) .. (109.3652,153.7333) --
      cycle(74.3902,136.2898) .. controls (70.9933,133.9581) and (67.6115,123.2929)
      .. (72.5676,131.3425) .. controls (72.9289,132.3219) and (79.0347,140.7760) ..
      (74.3902,136.2898) -- cycle(75.3359,126.6654) .. controls (74.7471,124.0079)
      and (76.8271,128.4288) .. (75.3359,126.6654) -- cycle(113.5388,123.1048) ..
      controls (105.3566,120.3225) and (128.7758,120.8069) .. (116.9857,123.7831) --
      (115.4446,123.6429) -- (113.5388,123.1048) -- (113.5388,123.1048) --
      cycle(132.1116,115.1364) .. controls (132.2953,111.7123) and
      (137.6293,113.8487) .. (132.1116,115.1364) -- cycle(139.1412,95.2606) ..
      controls (137.7252,89.2646) and (142.7469,94.5535) .. (139.6272,96.2902) --
      (139.1412,95.2606) -- cycle(0.0872,71.0995) .. controls (-0.2143,65.5523) and
      (4.4217,66.0913) .. (0.0872,71.0995) -- cycle(5.9486,51.8358) .. controls
      (8.5268,42.0593) and (8.4517,55.9487) .. (5.9486,51.8358) --
      cycle(101.3758,1.5022) .. controls (104.1751,0.8687) and (101.0824,2.7449) ..
      (101.3758,1.5022) -- cycle;

    \end{tikzpicture}
    }
}

\begin{document}

    \foreach\AA in{1,...,10000}{
        \makepage
        \newpage
    }

\end{document}

and include.tex with the second method

\documentclass{article}

\usepackage{tikz}
\usepackage{pdfpages}

\begin{document}

    \foreach\AA in{1,...,10000}{
        \includepdf{page.pdf}
    }

\end{document}
  • Where can we download 1200.jpg from? – AlexG Feb 15 '18 at 7:57
  • @AlexG just use any picture. I used it to increase the size of pdf – Michael Fraiman Feb 15 '18 at 8:02
  • @AlexG but if it matters, images2.onionstatic.com/clickhole/2035/8/16x9/1200.jpg – Michael Fraiman Feb 15 '18 at 8:03
  • Thanks. Now, the resulting PDF is even smaller than the \includepdf-based method 2. Of course, some overhead of PDF code is introduced for every document page which cannot be avoided. – AlexG Feb 15 '18 at 13:16
5

The xsavebox package can be used to somewhat further reduce the final PDF size and to considerably speed up the document processing by a factor of 30.

Pkg xsavebox uses a similar technique as \includepdf and its underlying LuaTeX primitive \saveimageresource in order to encapsulate content once for repeated usage. However, xsavebox allows encapsulating any typeset content, not just external graphics / document pages, to avoid multiple inclusion. Moreover, the two-files approach (method 2 of the original posting) can be avoided.

xsavebox provides \xsavebox/\xuseboxwhose usage is very similar to that of the standard LaTeX \savebox/\usebox pair of commands.

Also, this method doesn't seem to have a memory problem (TeX capacity).

\usepackage{xsavebox}
\xsbox{MyPage}{\parbox{\textwidth}{\makepage}}

...

\foreach\AA in{1,...,10000}{
  \xusebox{MyPage}
  \newpage
}

Complete example, based on manypages.tex

  • 11 s / 50 000 pages (pdfLaTeX)

  • 22 s / 50 000 pages (LuaLaTeX)


\documentclass{article}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xsavebox}
\usepackage{multido}  %\foreach crashes on large loop number
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}
\usepackage{mathtools}
\usetikzlibrary{shapes,calc}
\usepackage{ifpdf}

\geometry{margin=0.5cm}

\setlength{\parindent}{0pt}
    \definecolor{cd60952}{RGB}{214,9,82}
\newcommand{\makepage}{
    \includegraphics[width=\textwidth]{1200.jpg}
    \lipsum[1]

    \resizebox{\textwidth}{8cm}{
    \begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1, inner sep=0pt, outer sep=0pt]
    \path[fill=cd60952] (93.3195,230.9447) .. controls (59.0303,225.9343) and
      (31.1801,199.9495) .. (15.3715,170.2215) .. controls (5.5821,151.9201) and
      (1.0492,131.0592) .. (2.0713,110.3467) .. controls (2.9610,99.6354) and
      (-0.0316,88.4491) .. (3.6168,78.1309) .. controls (6.5315,67.3276) and
      (11.4331,57.5607) .. (18.0741,49.0323) .. controls (22.8424,36.3018) and
      (33.0142,26.6294) .. (43.3849,18.3207) .. controls (51.2637,15.0948) and
      (58.7196,8.4670) .. (67.3399,5.6708) .. controls (73.0270,2.1030) and
      (86.2192,-0.8740) .. (89.3376,0.7517) .. controls (87.1714,3.1299) and
      (96.8246,1.5167) .. (97.2769,4.1226) .. controls (107.4188,3.5384) and
      (115.9073,1.2904) .. (125.1827,6.6191) .. controls (130.1554,7.5866) and
      (134.4480,12.7054) .. (139.6428,10.2061) .. controls (146.0329,9.0034) and
      (150.3844,18.7601) .. (153.4049,15.9781) .. controls (167.0146,25.0067) and
      (179.0895,38.0628) .. (183.8766,53.8550) .. controls (180.8933,56.9429) and
      (186.6577,70.4714) .. (181.7816,59.7076) .. controls (180.8871,49.0368) and
      (168.0386,56.5647) .. (177.2058,61.0368) .. controls (179.2498,65.0404) and
      (182.0841,75.4132) .. (177.7802,71.7036) .. controls (180.1689,78.0221) and
      (180.9576,84.7644) .. (181.6522,89.9051) .. controls (179.1588,98.4216) and
      (176.1557,101.9826) .. (173.6042,111.8841) .. controls (170.9595,115.2866) and
      (171.0389,123.7597) .. (166.8992,120.5686) .. controls (165.2312,131.1547) and
      (155.5965,133.9765) .. (147.0796,141.2926) .. controls (132.2241,150.3707) and
      (112.9512,151.3272) .. (97.0139,144.6226) .. controls (84.6896,134.9490) and
      (70.7373,122.6945) .. (71.4998,105.4775) .. controls (70.3035,95.6431) and
      (74.2758,85.9523) .. (80.1058,78.2380) .. controls (88.0500,64.3879) and
      (106.9185,57.9312) .. (121.3004,65.4772) .. controls (125.4446,66.6683) and
      (135.3869,75.8586) .. (125.6405,70.0166) .. controls (107.1390,60.8500) and
      (82.4175,73.0004) .. (78.4654,93.3286) .. controls (76.0174,103.5799) and
      (80.0184,114.3881) .. (84.8167,123.4648) .. controls (93.9795,138.1966) and
      (113.4423,146.7081) .. (130.0863,140.0509) .. controls (139.2098,136.5960) and
      (146.4827,132.8242) .. (153.8322,125.8050) .. controls (158.6678,121.0523) and
      (159.0520,114.5674) .. (163.7343,109.5653) .. controls (167.1049,100.0360) and
      (164.7856,89.6203) .. (165.4952,79.5371) .. controls (164.0280,57.0736) and
      (149.4942,35.8534) .. (129.2629,26.0379) .. controls (115.1366,19.7678) and
      (99.0343,20.6064) .. (84.0979,22.4500) .. controls (80.5464,24.0798) and
      (67.4651,29.1244) .. (69.5458,30.0952) .. controls (72.5853,31.9093) and
      (56.7456,31.7609) .. (54.7847,36.8147) .. controls (50.3008,39.5539) and
      (57.4995,40.3709) .. (50.0780,41.5699) .. controls (38.7079,46.8575) and
      (29.9921,56.8048) .. (22.7900,66.8497) .. controls (24.2223,74.7738) and
      (14.2196,82.5255) .. (15.2267,91.6025) .. controls (14.1505,104.8645) and
      (11.1105,118.9822) .. (16.2776,131.6949) .. controls (15.8162,141.4332) and
      (19.5505,151.1444) .. (28.7610,155.2116) .. controls (30.8205,158.2024) and
      (33.8190,164.2180) .. (28.6238,161.1753) .. controls (32.7528,168.8945) and
      (34.4245,176.2610) .. (38.7270,183.6412) .. controls (45.0741,189.2992) and
      (47.5361,199.7078) .. (55.4974,202.5513) .. controls (63.5448,208.0481) and
      (63.3757,214.0812) .. (72.5802,217.5521) .. controls (79.7480,217.8771) and
      (85.3707,228.8788) .. (94.9911,228.7819) .. controls (100.7223,229.5682) and
      (108.6001,231.6152) .. (98.2271,231.1305) .. controls (96.5907,231.1102) and
      (94.9496,231.1072) .. (93.3195,230.9447) -- cycle(109.3652,153.7333) ..
      controls (96.4622,150.5469) and (82.9305,143.6407) .. (76.0433,131.9692) ..
      controls (79.5521,134.7556) and (88.1011,145.5911) .. (85.2368,139.0080) ..
      controls (93.3693,144.5154) and (101.6217,150.7951) .. (111.5236,152.3574) ..
      controls (116.2089,152.7513) and (130.2176,153.5790) .. (117.6684,154.3630) ..
      controls (114.8884,154.4545) and (112.0843,154.3802) .. (109.3652,153.7333) --
      cycle(74.3902,136.2898) .. controls (70.9933,133.9581) and (67.6115,123.2929)
      .. (72.5676,131.3425) .. controls (72.9289,132.3219) and (79.0347,140.7760) ..
      (74.3902,136.2898) -- cycle(75.3359,126.6654) .. controls (74.7471,124.0079)
      and (76.8271,128.4288) .. (75.3359,126.6654) -- cycle(113.5388,123.1048) ..
      controls (105.3566,120.3225) and (128.7758,120.8069) .. (116.9857,123.7831) --
      (115.4446,123.6429) -- (113.5388,123.1048) -- (113.5388,123.1048) --
      cycle(132.1116,115.1364) .. controls (132.2953,111.7123) and
      (137.6293,113.8487) .. (132.1116,115.1364) -- cycle(139.1412,95.2606) ..
      controls (137.7252,89.2646) and (142.7469,94.5535) .. (139.6272,96.2902) --
      (139.1412,95.2606) -- cycle(0.0872,71.0995) .. controls (-0.2143,65.5523) and
      (4.4217,66.0913) .. (0.0872,71.0995) -- cycle(5.9486,51.8358) .. controls
      (8.5268,42.0593) and (8.4517,55.9487) .. (5.9486,51.8358) --
      cycle(101.3758,1.5022) .. controls (104.1751,0.8687) and (101.0824,2.7449) ..
      (101.3758,1.5022) -- cycle;

    \end{tikzpicture}
    }
}

\pagestyle{empty}

\xsbox{MyPage}{\parbox{\textwidth}{\makepage}}

\begin{document}

    %\foreach\AA in{1,...,50000}{ %crashes
    \multido{}{50000}{
      \xusebox{MyPage}
      \newpage
    }

\end{document}
  • OK, getting 500,000 pages takes some minutes and the file is about 107 MB. It will compile much faster, if compilation can use more than one thread on my CPU. Probably that's an extra question. By the way, I wondered who in the world had that knowledge of xsavebox, until I opened the manual. Nice work! – Keks Dose Feb 15 '18 at 12:24
  • Thank you! Now the final PDF is even smaller than with method 2 (\includepdf) of the orig. posting. I forgot to insert \pagestyle{empty} which \includepdf does automatically. – AlexG Feb 15 '18 at 12:53
  • 1
    WOW! Fantastic, work extremely fast and not memory-consuming. Thx! – Michael Fraiman Feb 15 '18 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.