Lucee Flying Saucer PDF Engine not support chinese ttf

Lucee Flying Saucer PDF Engine not support chinese ttf

  1. lucee extension-pdf use api addFontDirectory
resolver.addFontDirectory(fontDirectory.getCanonicalPath(), fontembed);

2.flyingsaucer ITextFontResolver.java addFontDirectory call addFont by 2 argument String ,boolean

for (int i = 0; i < files.length; i++) {
       addFont(files[i].getAbsolutePath(), embedded);
}

3.flyingsaucer ITextFontResolver.java addFont with 2 argument will use BaseFont.CP1252

public void addFont(String path, boolean embedded)
            throws DocumentException, IOException {
        addFont(path, BaseFont.CP1252, embedded);
}

reference by

should be solve by 3 argument

fontResolver.addFont(files[i].getAbsolutePath(), BaseFont.IDENTITY_H, embedded);

Don’t forget to tell us about your stack!

OS: window 10
Java Version: 11.0.11 (AdoptOpenJDK) 64bit
Tomcat Version: WildFly / Undertow - 2.2.3.Final
Lucee Version: Lucee 5.3.9.44-SNAPSHOT

Hi,

Can you file an issue in jira and open a PR GitHub - lucee/extension-pdf: extension that is implementing the pdf functions and tags ?

Have you tried to install all the correct fonts first to the OS, then to the java.properties of the Java runtime environment?

On Windows, install the correct fonts in the Winroot/fonts
Restart the system

Next heck the environment path, make sure that your java runtime font.properties has the correct font mappings.

On windows systems, make sure you have installed additional keyboard layouts for the languages you are having issues with, even if you do not use those languages for the UI.

After you place the fonts in the correct location restart your lucee /tomcat instance
then try again.

I am a newbie in lucee ,i don’t understand about lucee extension.
I create a sample code with index.cfm use createObject(“java”)
The org.lucee.flyingSaucerPDF-9.1.20.jar copy from lucee extension
use addFont method MingLiU-01.ttf can work

https://github.com/gaias-jyh/lucee-flyingSaucerPDF/blob/main/index.cfm#L19

https://github.com/gaias-jyh/lucee-flyingSaucerPDF

1 Like

When using chinese TTF file in classic mode, you have to write pd4fonts.properties for PD4ML .

PD4ML or Lucee dont read Windows font directory.
cfdocument description in fontdirectory

But cfdocument is using “modern” by defaults Flying Saucer PDF Engine

<cfdocument format="PDF" type="classic" fontdirectory="D:\fonts">

i try chinese TTF with pd4fonts.properties file can be work

1 Like

https://luceeserver.atlassian.net/browse/LDEV-3836

Add the jira ticket on gaia-jyh’s behalf.

Owning to my poor knowledge about Java, I’m not able to continue with the PR. Sorry.

I added a patch to the issue [LDEV-3836] - Lucee. The Chinese fonts only render with the fontDirectory attribute. But that does not render without fontdirectory. is there any other way to render Chinese fonts without using font directory in the flying saucer engine?

3 Likes

I think this is a really old Java issue, not necessarily limited to lucee.

http://users.erols.com/eepeter/chinesecomputing/programming/java.html

Now this issue in the flying saucer engine was solved from the PDF extension version 1.1.0.7-SNAPSHOT

2 Likes