Skip to content

Another Chinese character issue #754

@rkhlin

Description

@rkhlin

Hi there,

I was using the Flying Saucer library before and it all went ok until I upgrade my Spring framework to v5 so that I have to look for a newer library to generate PDF with Chinese in it.

I had read quite a few posts and tried many ways, but still seeing ###. Not sure what is going on. Do I miss any step?
Please help.

My css file:
@charset "UTF-8";
@font-face {
font-family: "Arial Unicode MS";
src: url('arialuni.ttf');
}

  • {
    font-family: "Arial Unicode MS",sans-serif;
    }

HTML file:

<title>Testing</title>

每星期三
Every Wednesday

Java:
public static void main(String[] args) throws Exception {
try (OutputStream os = new FileOutputStream("E:/Temp/out.pdf")) {
PdfRendererBuilder builder = new PdfRendererBuilder();
// builder.useFont(new File("E:/Temp/arialuni.ttf"),"Arial Unicode MS");
builder.useFastMode();
builder.withUri("file:///E:/Temp/index.html");
builder.toStream(os);
builder.run();
}
}

Result:

out

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions