简体   繁体   English

在Firefox中查看包含表单的PDF

[英]View PDFs with forms in Firefox

I am working on a web application and there is a need to preview PDF in Firefox. 我正在开发一个Web应用程序,需要在Firefox中预览PDF。

Obviously I have embedded the PDF in the HTML code. 显然我已经在HTML代码中嵌入了PDF。 The problem is that these PDFs contain forms and I know that the built-in Firefox viewer cannot display forms. 问题是这些PDF包含表单,我知道内置的Firefox查看器无法显示表单。 Except the forms (which contain digital signatures) the rest of the document is displayed properly and in Chrome everything works fine (displaying the signatures too). 除了表单(包含数字签名),文档的其余部分正确显示,在Chrome中一切正常(显示签名)。

I want to ask which is the best approach to support the view of the whole document in Firefox. 我想问一下哪种方法是支持Firefox中整个文档的最佳方法。 The current version I am working on is 52.7.3 but I want to do the system scalable for future versions. 我正在处理的当前版本是52.7.3,但我希望系统可以在未来的版本中进行扩展。

I was thinking of transforming the PDF into a Base64 String and embed like that but trying this with some online demos did not work either (maybe the document is quite big?). 我正在考虑将PDF转换为Base64字符串并嵌入这样,但尝试使用一些在线演示也不起作用(也许文档很大?)。

The other posibility I was thinking of, is transforming the PDF in JPEG (or similar format) and preview like that. 我想到的另一个可能性是以JPEG(或类似格式)转换PDF并进行预览。 What do you think about that? 你觉得怎么样?

Is there any library to handle PDF files from Java/Javascript code that does not use embedded viewers? 是否有任何库来处理Java / Javascript代码中不使用嵌入式查看器的PDF文件? I tried PDF.js but I realised that it is using the built in viewers. 我试过PDF.js,但我意识到它正在使用内置的查看器。 Correct me on this If I am wrong. 如果我错了,请纠正我。

Is mandatory to open file specifically with Firefox? 是否必须专门用Firefox打开文件? If not, you can use Desktop.open(File) to open a file with the default application for PDF files. 如果没有,您可以使用Desktop.open(File)打开包含PDF文件的默认应用程序的文件。 ( https://docs.oracle.com/javase/7/docs/api/java/awt/Desktop.html ) https://docs.oracle.com/javase/7/docs/api/java/awt/Desktop.html

Desktop.open(File)

如果不必使用Firefox打开文件,则可以使用此文件打开PDF文件。

You could do something that is called "flattening". 你可以做一些被称为“扁平化”的事情。 This involves taking the form field appearance (graphics) and moving them directly into the page, and then removing the form fields themselves. 这涉及获取表单字段外观(图形)并将它们直接移动到页面中,然后删除表单字段本身。 Is also often done on annotations too. 也经常在注释上完成。

This ensures that the fields are visible (rendered) by every PDF reader, but also that users cannot possibly edit the fields (since the field is removed). 这可确保每个PDF阅读器都可以看到(呈现)字段,但用户也无法编辑字段(因为字段已删除)。

This would of course invalidate any e-signature, since you are modifying the PDF, but if you kept the original PDF, that should not be an issue. 这当然会使任何电子签名无效,因为您正在修改PDF,但如果保留原始PDF,则不应该是一个问题。

Once the fields are flattened, then Firefox/Pdf.js will show everything fine. 一旦字段变平,那么Firefox / Pdf.js将显示一切正常。

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

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