Flying Saucer realizes html to pdf (some problems, continuous update)

Flying Saucer realizes html to pdf (and some problems, continuous update)

There is a detailed introduction on the official website of FlyingSaucer.

Official website address: https://today.java.net/pub/a/today/2007/06/26/generating-pdfs-with-flying-saucer-and-itext.html#the-problem-with-pdfs

 

Chinese people have the following problems in the process of using FlyingSaucer to convert Html to PDF:

l The problem that Chinese is not displayed

l The content of <td> is too long, and the display is incomplete after converting to PDF

l There are a lot of articles on the Internet that provide solutions that do not solve the problem

 

When researching the above problem, two types of jars are used. The first one is the jar downloaded from the official website as shown in the following figure:

The other is to download the jar after others have modified the source code as follows:


 

Regarding the problem that Chinese is not displayed, there are three solutions as follows:

l Modify the source code yourself to solve the problem: unknown

l Use the source code modified by others to solve the problem: this is the most convenient, I recommend a person's blog to have a look, the address is: http://blog.csdn.net/shanliangliuxing/article/details/6833471 (if you need jar You can email me [email protected])

l Use the popular fonts on the Internet: The idea of ​​adding fonts is that fonts need to be added on the code side and in the html that needs to be converted. But I have tried all of them and none of them have succeeded! They are all reporting errors.

 

To sum up, it seems that using the modified source code directly is the most trouble-free, but I really want to get through the form of adding fonts, so if someone succeeds in using this form, please let me know ( [email protected] )

 

 

The solution to the problem that the content of <td> is too long and cannot be displayed in full:

l Modify the source code: unknown

l Use the source code modified by others: no one is available at present

l Ideas for adding styles to solve: It doesn't work at all after testing.

Summary: Can't get it right for now.

Supplement: Regarding the problem of Chinese characters with long line breaks, not only td exists, but div also has other tags, and the problem still exists after adding the width limit.

Supplement: A solution is provided in the article http://gaojunwei.iteye.com/blog/1996749. The Chinese display uses the method of adding fonts, which is OK after testing. Regarding Chinese line breaks, I tested table and div , the result is that even if the table is added with a width, the line wrapping problem cannot be solved, and the div can automatically wrap without adding a width.

 

 

 

 

 

 


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325822782&siteId=291194637