Java Web world PDF processing and preview those things

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/wjw521wjw521/article/details/102761339

  Preview PDF files in the browser, in some cases it is a relatively simple matter, why some cases do, in most cases, due to the outstanding features of modern browsers offer a preview PDF file is a simple thing. But in some cases, due to the special PDF file, we will be all kinds of problems in the preview function after the procedure to modify or signed PDF file, or in some cases, we do not want our customers to directly download PDF files, at this time we do not use the most direct way to PDF files directly exposed to the customer, or we need to preview the PDF file in the mobile terminal, all these circumstances, we will make the PDF preview not said at the beginning that simple change.

  Why PDF file rather special, if our daily work with PDF files, Adobe is undoubtedly the best software company ADOBE ACROBAT, but sometimes you edit PDF files, in some cases you will feel like a PDF file steaming is not bad, cook unfamiliar, do not hammer plaque, speculation does not burst, a copper ring pendant pendant peas, PDF transfer Word, Word turn PDF, PDF transfer pictures, PDF turn HTML. And because of the special nature of Chinese programming in the world, but also to bring a variety of processing PDF garbage problem.

 The following is quoted from some Wikipedia About PDF files:

Adobe PDF is developed in the 1990s, a file format for application-independent software, hardware and operating system displayed a document, including text and images. Based on the PostScript language, each PDF file encapsulates the complete description of a fixed-layout document plane, including text, fonts, vector graphics, raster images, and other information required to display the document. PDF is standardized in 2008 as an open format ISO 32000, and no longer need any royalties.

No matter how downright PDF file, we still have to overcome to overcome, if only in the development of web applications Preview PDF PC side, you can find some nice plugins to accomplish these functions, such as jquery.media.js.

If you preview the mobile side, we can also use quite good plugins:

pdf.js github Address: https://github.com/mozilla/pdf.js

pdfh5 github Address:   https://github.com/gjTool/pdfh5

Of course, if we preview the PDF file using the above general method is basically no problem, but if we use the program PDF been treated, such as: content filling form fields, signature and other operations, due to the above principles plug (pdf.js pdfh5) in (on PDF file to re-render the display), during rendering, or other problems due to the special nature of fonts or operating system, there will be some padding content or signature content is not displayed or not displayed on a mobile device or some kind of Chinese garbage problem .

When experiencing these problems, we should look for other ways, such as display problems after rendering, we can not display PDF, you can display the picture after the conversion, which in the Java world, there are many tools for you to use, such as: PDFBox ( HTTPS: // pdfbox.apache.org/ ), ICEpdf ( http://www.icesoft.org/java/projects/ICEpdf/overview.jsf ) and the like.

If you encounter Chinese garbage problem, usually the font problem, if you show properly on Windows, deployed to a production environment such as Linux on the server, you can copy the font into the Linux system on Windows, refresh the font used, the relevant specific solutions search.

 

end

If wrong, please correct me

 

Guess you like

Origin blog.csdn.net/wjw521wjw521/article/details/102761339
Recommended