I am using \includegraphics
in pdflatex to extract and display single pages from a pdf file with 30 pages. Each page is a graph and the pdf contains up to 30 graphs. The resulting pdf is enormous (over 9MB) even though I only have 10 or so figures (plots using Python's matplotlib).
This is what I do within a figure environment to display a figure. 17 is the page number of the graph within AllGraphs.pdf
\includegraphics[page=17,scale=0.5]{AllGraphs.pdf}
I have the impression that pdflatex is embedding the entire pdf file of graphs in my document each time I include a single graph.
If so, is there any way to stop this so that only the displayed pdf file is shown.
Update: I have just done an analysis. Each time I add a call to includegraphics the size of the resulting file increases roughly by about a third to a half the size of the entire pdf from which I am extracting the single page (there are 36 pages in each pdf file). Without figures my pdf is about 500k. With 23 images it is over 9MB. That makes about 370k per image. Each file with 36 images is about 700-900k. I was expecting 900/36 equals about 30k per image. Another theory is that my inclusion of the pdf is doing something to the resolution of the included image.
Update 2: The pdf with the initial figures (36 to a file) is produced using PdfPages in Python. I call the following code for each graph. pp is the reference to the plotting object created by calling
pp= PdfPages(fileName)
The for each figure I have
fig = plt.figure(figsize=(8.27, 11.69), dpi=100)
... plotting lines ...
plt.tight_layout()
plt.legend(loc='best')
plt.draw()
pp.savefig(fig)
The file appears to be a perfectly ordinary pdf with 36 pages and a graph on each.
pdftk burst
and just include the pages you want.pdfpages
package lets you insert a selection of pages from an external pdf file.\usepackage{pdfpages}
in your preamble and then\includepdf[pages={3,5,6,8}]{your-pdf-file.pdf}
.