[Tex/LaTex] How to set size of pdf page in pixels and put a background image

backgroundsgraphicsmargins

I need to create certificates in pdf. I have an image, where the text must be put to the appropriate place. I managed to set the correct pdf page size and all margins, except the top:

\documentclass{standalone}
\usepackage[paperwidth=1055px,paperheight=700px]{geometry}
\usepackage{graphicx}
\setlength{\oddsidemargin}{0px}
\begin{document}
\includegraphics{bg.png}
\end{document}

But there is little top margin, that shifts the image out of the page.

enter image description here

How can I set the picture as the background of this page? And remove the margin?

Then I'll use tikz to position the text.

Best Answer

I downloaded the PNG of your self answer and did

file QXom4.png

getting the answer

QXom4.png: PNG image data, 600 x 399, 8-bit colormap, non-interlaced

Then I created the following file:

\documentclass{article}
\usepackage[margin=0pt,paperheight=399bp,paperwidth=600bp]{geometry}
\usepackage{graphicx}
\parindent=0pt
\pagestyle{empty}
\begin{document}
\includegraphics{QXom4.png}
\end{document}

This produced a PDF file with no margin whatsoever.

However, the simpler

\documentclass{standalone}
\usepackage{graphicx}
\begin{document}
\includegraphics{QXom4.png}
\end{document}

did the same, because standalone automatically clips the PDF to the dimension of its contents.

The default value of 1px is equal to 1bp. Well, 1px is 65782 scaled points, while 1bp is 65781 scaled points (1pt = 65536 scaled points, the difference is negligible). It's not recommended to use it (if you don't set it in your document with \pdfpxdimen), because it can be changed at format creation.

Related Question