Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export to pdf error (when Chinese in content ) #533

Closed
sholong opened this issue Dec 5, 2017 · 5 comments
Closed

export to pdf error (when Chinese in content ) #533

sholong opened this issue Dec 5, 2017 · 5 comments

Comments

@sholong
Copy link

sholong commented Dec 5, 2017

tim 20171205183319
tim 20171205183350

@vsch
Copy link
Owner

vsch commented Dec 8, 2017

@sholong, it is a limitation of the openhtmltopdf library which is used by the plugin.

The library needs additional fonts that have the necessary characters and html changes that will change the text to use those fonts.

This is covered by the issue for the library: danfickle/openhtmltopdf#129

I am looking into how this can be handled by the plugin.

@vsch
Copy link
Owner

vsch commented Jan 24, 2019

@sholong, fixed in next EAP for non-latin fonts by including Noto Serif/Sans/Mono fonts with the plugin allowing adding noto-serif, noto-sans and noto-mono families to CSS to allow PDF to use these for rendering text.

However, the PDF converter requires TrueType fonts and Noto CJK fonts are OpenFonts which cannot be used. The solution is to download a TrueType Unicode font that supports CJK character set and add it to the custom rendering profile to be used for PDF.

For my test I used arialuni.ttf from https://www.wfonts.com/font/arial-unicode-ms

By creating a custom rendering profile for PDF export with CSS Text (see Rendering-Profiles-Settings):

@font-face {
  font-family: 'noto-cjk';
  src: url('file:///Users/vlad/src/fonts/arialuni.ttf');
  font-weight: normal;
  font-style: normal;	
}

.markdown-body,
.wiki-body {
    font-family: 'noto-sans', 'noto-cjk', Arial, "Helvetica Neue", "Segoe UI", freesans, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

var,
code,
kbd,
pre {
    font: 0.9em 'noto-mono', Consolas,Inconsolata,Courier,monospace;
}

And turning off all stylesheets and turning off HTML Generation option: Add page header for the custom profile.

Then setting Rendering Settings PDF profile to the above created rendering profile so PDF uses the custom CSS and HTML Generation.

The following markdown:

1. 0.40.68 test
   ------------

## Reply

Я ожидал увидеть в PDF текст и изображения такие же, как в превью
плагина, но что-то пошло не так

`Я ожидал`

```puml
A -> D 
```

|  字段名  | 说明                         | 是否必须 |  备注  |
|---------|:----------------------------|---------|--------|
| status  | 状态码                       || String |
| result  | 内容主体                     || Object |
| message | 异常情况的错误信息,供显示给用户 || String |
[  ]

异常情 况 的 错误 信息, mixed chars width wrapping mode test 供显 示给用户
异常情况的 错 误信息 供显 示给 用户 异常情 况的错误 信息,供显示给用户
异常情况的错 误信息,供显 示给用户 异常情况 的错误信息,供显示给用户 异常 情况的
错 误 信息,供显 示给 用户

Renders in PDF as:

screenshot_533pdf

Exports to PDF 533.pdf

I will post here when the EAP is available for download.

@vsch
Copy link
Owner

vsch commented Jan 24, 2019

EAP update with a fix for the issue is available. (see Rendering-Profiles-Settings)

Installing EAP Plugin Version

@HZ89
Copy link

HZ89 commented May 11, 2020

it is not work for me, plugin version is 3.0.197.72

@vsch
Copy link
Owner

vsch commented May 11, 2020

@HZ89, what exactly is not working for you?

What OS and IDE are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants