同一个 PDF 文档的打印效果是否与屏幕上显示的效果不同?
例如,您向客户发送包含发票的 PDF 文档,您希望他们在屏幕上以彩色形式查看您的徽标,但在打印时,您希望以可打印的黑白版本打印您的徽标,是这样吗?可能的?谢谢。
For example, you send a PDF document containing an invoice to a client, you want them to view your logo in it in color on the screen but when printed, you want your logo to be printed in its printable black / white version, is that possible? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用图层来设置某些内容在打印时显示,而其他内容在查看时显示。
YOu can use Layers to set certain things to appear on printing and others on viewing.
是的,PDF 规范允许创建此类 PDF 文件。但您还必须使用一个工具来利用 PDF 规范中的此功能。
Yes, PDF specification allows creation of such PDF files. But you also must use a tool that lets you take advantage of this feature in PDF specification.
有几种方法可以做到这一点。
表单字段可以设置为“仅打印”或“仅屏幕”。 “仅图标”按钮字段可以具有任意外观。 Acrobat 的 UI 将允许您导入任何 PDF 页面,而允许您生成字段的 API 通常将允许您绘制自己的外观。
可选内容组(也称为图层)。 OCG 可以具有单独的屏幕和打印打开和关闭状态。 OCG 是一项相对高级的功能,仅由更成熟的 API 支持。
我是 iText 的粉丝(和贡献者),iText 是一个 Java 库,它非常适合这两种方法。构建纯图标按钮会更容易。
这假设您知道生成 PDF 时要使用的矩形,并且有一个包含黑白徽标的 PDF 页面。
注意:iText 根据 AGPL 获得许可,这要求任何有权访问程序输出的人也有权访问源代码。又名:商业敌对。或者您可以购买商业许可证。以前的版本在 MPL 或 LGPL 下可用,但不再受支持,除了这样的地方,即使如此,答案也越来越多地“获取更新的版本”。
There are a couple ways to do it.
Form fields can be set to "Print only" or "screen only". "Icon Only" Pushbutton fields can have an arbitrary appearance. Acrobat's UI will let you import any PDF page, and APIs that let you generate fields will generally let you draw your own appearances.
Optional Content Groups (aka layers). An OCG can have separate ON and OFF states for screen and print. OCGs are a relatively advanced feature, only supported by more mature APIs.
I'm a fan (and contributor) to iText, a Java library which is quite capable of both methods. It would be easier to build the icon-only button.
This presumes you know the rectangle to use when generating the PDF, and have a PDF page holding the black-and-white logo.
NOTE: iText is licensed under the AGPL, which requires that anyone with access to the program's OUTPUT also have access to the source. AKA: Commercially hostile. Or you can buy a commercial license. Previous versions were available under the MPL or LGPL, but are no longer supported, save in places like this, Even then the answer is increasingly "get a newer version".