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:


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.

  • Related: Package for certificates – Werner Apr 11 '13 at 15:58
  • Wouldn't margin=0pt among the option to geometry help? I would never use px as unit: use bp if you know the precise dimensions of the image in Postscript points (72bp=1in). – egreg Apr 11 '13 at 21:24
  • @egreg 1. "Wouldn't margin=0pt among the option to geometry help?" - I tried it, but it didn't work. Produces margins at the bottom & right of the page. I used oddsidemargin & topmargin. Look at my answer below. 2. "I would never use px as unit" - they gave me a picture and told to create a pdf of the same size & use it as a background. That's why I used px. Is bp better in this case as well? – user4035 Apr 11 '13 at 21:35

pdftex (and most likely also luatex, also I haven't checked) provides a primitive \pdfpxdimen and the unit px. See the pdftex manual, section 7.9. An example from the manual:

\pdfpxdimen=1in % 1 dpi
\divide\pdfpxdimen by 96 % 96 dpi

px should work with the geometry package.

  • Yes, I did it with geometry package. But can't remove the top and left margins. – user4035 Apr 11 '13 at 15:09
  • 3
    @user4035: It's not nice to remove parts of your question after somebody answered them. Can I at least get an upvote? :-) – Martin Schröder Apr 11 '13 at 15:10
  • Sorry, I saw your answer exactly after I saved the edit :). – user4035 Apr 11 '13 at 15:11

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:


This produced a PDF file with no margin whatsoever.

However, the simpler


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.

  • I improved my answer, using your suggestions. With standalone the code is much better. – user4035 Apr 11 '13 at 21:55

I did it:

    \draw node[inner sep=0] {\includegraphics{bg.png}};
    \draw (1, 1) node[align=center] {mr. Dummy\\
      Group Name};
    \node at (7.4cm, -3.09cm) {10.01.2013};

Gives this:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.