I know how to include pdf pages using package pdfpages and do it all the time, but always had problem with getting the page centered and scaling.
I am now trying to learn how to use tikzpicture to do the same, since I'd like to take advantage of overlay option, as in
\begin{tikzpicture}[remember picture,overlay]
Which I found, on a single page, works well. The problem is that I have to use a loop, since when using \includegraphics[page=??]{file2.pdf} the page number has to be a single page. I can't use something as \includepdf[page={2-}] for example, to tell it to read pages 2 to the end of the pdf file.
Here is a MWE to read one page in tickz which works fine:
\documentclass[11pt]{report}
\usepackage{amsmath,mathtools}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage{tikz}
\usepackage{pgffor}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node[inner sep=0pt] at (current page.center)
{\includegraphics[page=1]{file2.pdf}};
\end{tikzpicture}
\end{document}
Now, I wanted to do the same, but not just for page 1, but for all the pages. This is what I tried
\documentclass[11pt]{report}
\usepackage{amsmath,mathtools}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage{tikz}
\usepackage{pgffor}
\begin{document}
\pdfximage{file2.pdf} %find how many pages
There are \the\pdflastximagepages\ pages in the file. Now
we will include them:
\begin{tikzpicture}[remember picture,overlay]
\foreach \index in {1, ... ,\the\pdflastximagepages}
{
\node[inner sep=0pt] at (current page.center)
{\includegraphics[page=\index]{file2.pdf}};
}
\end{tikzpicture}
\end{document}
But this gives error Paragraph ended before \pgffor@dots@stripcontext was complete.
I also tried to put the loop outside, and the tikzpicture inside
\documentclass[11pt]{report}
\usepackage{amsmath,mathtools}
\usepackage{graphicx}
\usepackage{pdfpages}
\usepackage{tikz}
\usepackage{pgffor}
\begin{document}
\pdfximage{file2.pdf}
\foreach \index in {1, ... ,\the\pdflastximagepages}
{
\begin{tikzpicture}[remember picture,overlay]
\node[inner sep=0pt] at (current page.center)
{\includegraphics[page=\index]{file2.pdf}};
\end{tikzpicture}
}
\end{document}
Same problem. Clearly I am lost and do not know what I am doing so I am asking experts help in getting the syntax right.
references:


\begin{document} test \installbackgrounds[17]{file2.pdf}\end{document}but the pdf file is not loaded? it looks like your solution for putting background on existing pages? But I need to actually include the external pdf pages in the document. Not as background to existing pages, but as new pages. thanks. – Nasser Dec 26 '14 at 02:04overlayoption which, well, overlays things rather than putting each thing in a separate space. Why not just use\includepdf[options]{}if you want to include the pages of the PDF as regular pages? – cfr Dec 26 '14 at 02:15\includepdf{}what you want? – cfr Dec 26 '14 at 03:07overlay, this will happen. By default, nodes are placed at(0,0). You are specifying a different point, but always the same. In the second case, it happens because you are telling TiKZ tooverlayeach image. – cfr Dec 26 '14 at 03:29Paragraph ended before \pgffor@dots@stripcontext was complete. I updated my question. So case is now all closed. Thanks for your input. – Nasser Dec 26 '14 at 04:21