[Tex/LaTex] How to include PDF absolute positioned and scaled

graphicspositioningtikz-pgf

Actually i started to write this question, but during the writing i discovered the answer. Althougth this information may useful also for others, so i send this question, after i'll answer it.

I'm trying to make a pdf with totally filled page (no margins), and include graphics from other pdf files, and positioning them relative to the page edge.
What i did:
— set margins and offsets to zero:

\usepackage[paperwidth=79mm,paperheight=85mm,margin=0cm,left=0cm,bottom=0mm]{geometry}
\setlength{\marginparwidth}{0mm}
\setlength{\marginparsep}{0mm}
\setlength{\hoffset}{-1in}
\setlength{\voffset}{-1in}
\setlength{\topmargin}{0mm}
\setlength{\headheight}{0mm}
\setlength{\headsep}{0mm}
\setlength{\footskip}{0mm}
\setlength{\textheight}{85mm}
\setlength{\textwidth}{79mm}

— defining a tikz node style:

\tikzstyle{default}=[anchor=north west,draw=red,text width=79mm]

— seting a grid:

\tikzset{grid/.style={gray,very thin,opacity=1}}

— begin tikzpicture with grid:

\begin{tikzpicture}[yscale=-0.1,xscale=0.1]
\draw[grid] (0,0) grid (79,85);

— and include graphics in the width of page

\node[badge] at (0,0) {
\includegraphics[width=79mm]{test.pdf}
};
\end{tikzpicture}

The problem is, that the edge of the box (red), the grid and the edge of the page seems to be totaly the same, but the included pdf's edges have some offset.
The question: which parameters should i modify to move them in total cover?

So the whole file looks like this:

\documentclass{minimal}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{graphicx}
\usepackage[paperwidth=79mm,paperheight=85mm,margin=0cm,left=0cm,bottom=0mm]{geometry}
\usepackage{fullpage}
\setlength{\marginparwidth}{0mm}
\setlength{\marginparsep}{0mm}
\setlength{\hoffset}{-1in}
\setlength{\voffset}{-1in}
\setlength{\topmargin}{0mm}
\setlength{\headheight}{0mm}
\setlength{\headsep}{0mm}
\setlength{\footskip}{0mm}
\setlength{\textheight}{85mm}
\setlength{\textwidth}{79mm}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes,shadows,calc}
\usepackage{xcolor,color}
\tikzstyle{default}=[anchor=north west,draw=red,text width=79mmdiscovered]
\tikzset{grid/.style={gray,very thin,opacity=1}}
\begin{document}
\pagestyle{empty}
\setlength{\parindent}{0em}
\begin{tikzpicture}[yscale=-0.1,xscale=0.1]
\draw[grid] (0,0) grid (79,85);
    \node[default] at (0,0) {
        \includegraphics[width=79mm]{test.pdf}
    };
\end{tikzpicture}
\end{document}

Best Answer

The offset prooved to be the inner sep of the TikZ \node. By setting this to zero, the included PDF becomes exactly fit to the top left corner of the page:

\tikzstyle{default}=[anchor=north west,draw=red,text width=79mm,inner sep=0pt]

I know, it's so obvious, but for me it took one hour to find it.