简体   繁体   English

如何在xsl / apache-fop中添加不可打印的图像

[英]How to add a non-printable image in xsl / apache-fop

I'm trying to generate an xsl to be printed in a pre-printed sheet which works fine. 我正在尝试生成要在预打印纸上打印的xsl,效果很好。

Now i want to give the user a better previsualization (in the pdf screen version) adding a background image which emulates the "pre-printed" stuf on the sheet to give the user a "context" of what is he printing. 现在,我想为用户提供更好的预可视化效果(在pdf屏幕版本中),并添加一个背景图像,该图像模仿纸张上的“预打印” stuf,从而为用户提供他所打印内容的“上下文”。

The question is: Is there any way I can set a background image in xsl (using apache fop) visible only in pdf but not in the printed version of it? 问题是:有什么方法可以在xsl中设置背景图像(使用apap fop),仅在pdf中可见,而在印刷版本中不可见?

Thank you all for reading or givin any advice. 谢谢大家的阅读或给予任何建议。

Although as the comments state, you can't have content in the PDF that does not come out in a physical printed copy, here is one possible work around for you. 尽管如注释所示,PDF中不能包含没有以物理打印副本形式出现的内容,但是这里有一种可能的解决方法。 Depending on how your users are ultimately going to be using FOP for PDF rendering and how your a driving the work flow, it's possible to pass a parameter into an xslt file before the transofrmation phase is run, so potentially, you could do a dual rendering of the same PDF, one that is presented to the user where the background image is enabled, and one that gets printed, you could just set a variable similar to how they do in this Example , and call it something like $isPreview, and just use a simple if or choose statement to check for 'Y' or 'N'. 根据用户最终将使用FOP进行PDF渲染的方式以及驱动工作流程的方式,可以在运行transfrmation阶段之前将参数传递到xslt文件中,因此有可能进行双重渲染在相同的PDF中,一个在启用背景图片的情况下呈现给用户,另一个在打印时显示,您可以设置一个类似于他们在此Example中的操作的变量,然后将其命名为$ isPreview,使用简单的if或select语句检查“ Y”或“ N”。

Since you are sending to a printer, you may even want to take advantage of FOP's ability to generate to Postscript rather than PDF, I've used this feature quite extensively for print documents using FOP while also producing a PDF copy for electronic delivery via email or hosted services, and I've yet to find any discrepancy between the PDF rendering and what is printed after sending a rendered postscript file, so it should work well for you as well. 由于要发送到打印机,您甚至可能想利用FOP生成Postscript而不是PDF的功能,所以我已经在使用FOP的打印文档中广泛使用了此功能,同时还生成了PDF副本以通过电子邮件进行电子传递或托管服务,但我还没有发现PDF渲染与发送渲染的后记文件后打印的内容之间存在任何差异,因此它也应该适合您。

As I said, this is not truly a solution to your problem as you've presented it, but as a work around, it could get you the desired results if your clever about how you implement it. 就像我说的那样,这并不是您提出的问题的真正解决方案,但是作为变通办法,如果您聪明地实现它,它可以为您带来预期的结果。

I don;t think the statement that it is not possible is true, I am just not sure how to create such a PDF with FOP. 我不认为不可能的说法是正确的,我只是不确定如何 FOP创建这样的PDF。 Certainly you can add an image field . 当然,您可以添加一个image 字段 One would use a button field and place the image in the button. 可以使用按钮字段并将图像放置在按钮中。 Then you would set the properties of that button to not print (printable false). 然后,您可以将该按钮的属性设置为不打印(可打印的false)。

PDF support images in fields: https://answers.acrobatusers.com/adding-image-field-form-q41825.aspx 字段中的PDF支持图像: https : //answers.acrobatusers.com/adding-image-field-form-q41825.aspx

RenderX supports PDF Form fields but I do not see where they support an image inside the button, only text: http://www.renderx.com/reference.html#PDF%20Forms . RenderX支持PDF Form字段,但我看不到它们在按钮内的哪个位置支持图像,只有文本: http : //www.renderx.com/reference.html#PDF%20Forms But they do support setting a field to "printable". 但是他们确实支持将字段设置为“可打印”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM