How to make a pdf printout occupy the entire A4 page
I use jboss seam iText module to generate a sample pdf file, which by default renders with a page magnification of 143%. When I take a prin开发者_如何学运维t out, the output doesn't occupy the entire page though. What settings should I modify to make the print out use the entire sheet.
If seam-pdf is what your are using, settings for document size are in the <document>
tag:
<p:document type="pdf"
pageSize="A4"
orientation="portrait"
margings="2cm, 2cm, 2cm, 2cm"
disposition="attachment"
title="Document title"
subject="Document subject (appears in the doc properties from pdf viewer)"
author="Document Author"
creator="Document Creator">
<!-- define the page here -->
</p:document>
You can change your initial page size to be A4.
Document doc = new Document(PageSize.A4);
You can ask your users to configure their printer properly. In Reader X there's a "Page Scaling" drop list, and one of the options is "Fit to Printable Area". I believe previous versions had a check box for the same control, but I'm not sure.
You can change the initial page view, but that won't change the printing behavior... at least not the way you want. See PdfViewerPreferences, implemented by PdfWriter
.
There's also a javascript method, doc.print(...)
, that can control all of that without user input, but the "no user input" parameters require Special Execution Privileges... you might be able to arrange that with certificate security and some user settings, but then again, you might not.
精彩评论