How to fix the page size problem?

In LaTeX when generating PDFs, it sometimes does not respect the margings. Add the code below to fix this:

\special{papersize=8.5in,11in}
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth