# Margin changes in converting DVI to PDF

I have a 1 inch top margin in all the pages that I have in my DVI file. When I convert this to PDF however the top margin reduces! I am not sure why this is happening. Could someone tell me how to ensure a top margin of at least 1 inch in the PDF?

-
Which paper size do you expect to get, letter or A4? Do you produce PDF directly from DVI, using dvipdfmx? If yes, try dvipdfmx -p a4 or dvipdfmx -p letter. In case you produce PDF via Postscript, is the intermediate PS correctly sized? Try dvips -t a4, if not and you want A4. The final PDF should be correctly sized, if you do conversion with ps2pdf -sPAPERSIZE=a4 ... (or similar for letter). For Windows, the option must read -sPAPERSIZE#a4. – AlexG Jun 28 '11 at 7:59
The following produces constant 1in margins in both DVI and PDF (using dvipdf) for me. It also works when using letterpaper instead. \documentclass[a4paper]{article} \usepackage[margin=1in]{geometry} \usepackage{lipsum} \begin{document} \lipsum[1-20] \end{document}  Please provide a MWE by yourself so we can see better what's going wrong. – Martin Scharrer Jun 28 '11 at 20:03
@rty: Try to use dvips to convert DVI -> PostScript, and then ps2pdf to convert PostScript -> PDF. Then you can specify the appropriate paper size on the dvips command line. For example, to get the A4 paper size, first run dvips -t a4 foo.dvi and then ps2pdf foo.ps foo.pdf. For letter paper size, run dvips -t letter foo.dvi, etc. The paper size specified on dvips command line should match the paper size selected in the Latex source code. – Jukka Suomela Jun 28 '11 at 20:04
And in future, I strongly recommend that you switch to pdflatex. It will produce a PDF document directly, without any intermediate formats, with the right paper size. – Jukka Suomela Jun 28 '11 at 20:05
@Martin: (At least my version of) dvipdf internally runs dvips with default settings. Depending on the system configuration, dvips might use letter or A4 paper size by default. Hence if it works for you, it does not necessarily work for someone else... – Jukka Suomela Jun 28 '11 at 20:08

As Alexander Grahn suggested - instead of using dvipdf you could do it in two steps:

1. Run dvips with the desired paper option, such as

dvips -t a4 file.dvi

2. Run ps2pdf with the desired paper option, it takes the same as gs aka ghostscript, such as

ps2pdf -sPAPERSIZE=a4 file.ps


I recommend using pdfLaTeX for directly producing PDF without those conversions, it has further benefits for example its microtypographic capabilities.

-