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

Problem with display cyrillic characters as # #422

Closed
MichaelZaleskovsky opened this issue Dec 5, 2019 · 2 comments
Closed

Problem with display cyrillic characters as # #422

MichaelZaleskovsky opened this issue Dec 5, 2019 · 2 comments

Comments

@MichaelZaleskovsky
Copy link

MichaelZaleskovsky commented Dec 5, 2019

Hi! I have the problem with cyrillic characters with openhtmltopdf.
I want to get PDF from html, which contains cyrillic. I use this library in servlet.
But the cyrillic simbols converted to #

I use pdfBulider in this way:
pdfBuilder
.useFastMode()
.withHtmlContent(html, "/")
.toStream(stream)
.run();
and html string contains:

<style> @font-face { font-family: "PT Sans"; src: url("https://fonts.googleapis.com/css?family=PT+Sans&subset=cyrillic"); } body { font-family: 'PT Sans', Geneva, Arial, Helvetica, sans-serif; } </style>
But it doesn't help me.
Could you help me - what is the problem?

@syjer
Copy link
Contributor

syjer commented Dec 5, 2019

hi @MichaelZaleskovsky ,

I don't think openhtmltopdf support the css generated by fonts.googleapis.com. You need to follow the guide https://github.com/danfickle/openhtmltopdf/wiki/Fonts#css-font-embedding-example .

So basically, you download your font (in TTF format) and define your "PT Sans" font as:

@font-face {
font-family: 'PT Sans';
src: url(fonts/PTSans-Regular.ttf);
font-weight: normal;
font-style: normal;
}

the url is where your font is :)

Alternatively, you can register your font programmatically as described in https://github.com/danfickle/openhtmltopdf/wiki/Fonts#programatically-adding-fonts so you can avoid to define using @font-face .

https://fonts.google.com/specimen/PT+Sans?selection.family=PT+Sans -> you need to download the font, in the zip you will find PTSans-Regular.ttf which you can then use.

danfickle added a commit that referenced this issue Dec 9, 2019
with format tags. We select the truetype font. This allows some Google font stylesheets to be used (where a truetype font is provided), however, consider the network load issue if running a template multiple times.

With tests for:
+ Simple uri which was previously all we supported.
+ Multiple uris/local with format tags.
+ Import of google CSS font sheet (manual test to avoid network load on each test run).
@danfickle
Copy link
Owner

Assumed solved, reopen if you need to.

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

No branches or pull requests

3 participants