# How to extract Tikz images from a PDF

I have a paper in PDF, created using Latex and Tikz. Now I need to produce individual files for the images, one file per image.

Since I have the source, I could manually copy and paste (let me see..) twenty-nine separate pieces of code, add some scaffolding, and then produce the files with Latex. But perhaps there is a simpler way?

I tried pdfimages but it produced nothing.

Any ideas anybody?

As you have the source, it is very easy to produce individual files for each tikzpicture by using the externalize library.

The following example needs to be compiled with -shell-escape enabled and will produce not only the document itself, but also document-figure0.pdf and document-figure1.pdf.

As an additional advantage, this will speed up the compilation of your document, because the tikzpictures will only be redone if they were changed.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize

\begin{document}

\begin{tikzpicture}
\fill[red] (0,0) circle (1);
\end{tikzpicture}

\begin{tikzpicture}
\fill[blue] (0,0) rectangle (1,1);
\end{tikzpicture}

\end{document}