且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何防止PDF格式的页面大小调整?

更新时间:2023-10-31 22:46:16

请看看 PrintPreferences 一个例子。在此示例中,解释了几个打印首选项。对您来说重要的一行将确保在打印时不缩放页面:

Please take a look at the PrintPreferences example. In this example, several print preferences are explained. The line that is important to you, will make sure that the page isn't scaled when printed:

writer.addViewerPreference(PdfName.PRINTSCALING, PdfName.NONE);

这是您可以设置以影响打印设置的唯一参数。您无法告诉查看者它需要使页面符合打印机页面的大小。您只能通过将 PRINTSCALING 设置为 NONE 来指示查看者需要采取实际大小。

This is the only parameter you can set to influence the print setting. You can't tell a viewer that it needs to fit the page to the size of the printer page. You can only instruct the viewer that the actual size needs to be taken, by setting the PRINTSCALING to NONE.

如果你想要其他一些行为,你会要求在PDF中找不到的东西。

If you want some other behavior, you're asking for something that is impossible in PDF.