Text cannot be displayed when using POI to convert word to PDF in linux java

background:

When using POI to convert word to PDF during local debugging on Windows, the reason why the PDF cannot display text and the solution are:
Mine is on linux7.9. The reason is that Chinese characters are normal when generating world, but there are no Chinese characters when converting to pdf. After many investigations, I found that there are none
Song Dynasty:

Reason 1: There is no problem with the font. The font used in word must be installed on the system (windows or linux), otherwise the PDF cannot display text. Download the required font and copy it to

1) Under the C:\Windows\Fonts folder of windows, then restart the machine to load the newly added fonts into the memory.

2) In Linux system, put the fonts under the /usr/share/fonts folder,

fc-list #View font list
mkfontscale #Create font cache
mkfontdir
fc-cache -fv #Refresh cache

You can create a directory in this directory and put your fonts in the directory. Remember that the directory permissions are 755 and the font permissions are 644. Refresh it when you are done, but it will not restart.

cp xx.ttf /usr/share/fonts/myfonts
mkfontscale
mkfontdir
#-f扫行,-v过程
fc-cache -fv

Reason 2: Font usage problem. When debugging the local Windows system, text cannot be displayed when converting word to PDF. Because of the bolding function used in word, sometimes POI cannot bold when converting word to PDF, resulting in text not appearing in the PDF.

Solution: Remove all bold fonts and use Song Ti fonts. The font size can be set as desired.
I use Song Ti font size 11. The text can appear in the PDF, but the bold cannot. .
Insert image description here

———————————————
Original text link: https://blog.csdn.net/qq_42889751/article/details/120350523

Guess you like

Origin blog.csdn.net/csl12919/article/details/130145167