innoveit / play2-pdf

A PDF module for Play Framework 2
MIT License
77 stars 22 forks source link

Problems with encoding. #21

Closed vasiliy-komarov closed 7 years ago

vasiliy-komarov commented 7 years ago

Hello. Please look, can you have any ideas what could be the problem. When generating pdf there is a problem with the symbols.

example: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> @*<meta charset="utf-8"/>*@ <title>Title</title> </head> <body> <div class="pdf-content"> <div class="pdf-label">Label</div> <div> ТЕКСТ Russian </div> </div>
</body> </html>

Html render = template.render(); byte[] content = pdfGenerator.toBytes(render, "http://localhost:9001");

if i use scala template without tag 'meta charset="utf-8', then word 'ТЕКСТ' have wrond encode. wrong

if i use scala template with tag 'meta charset="utf-8', then word 'ТЕКСТ' disappear... disappear

html it turns out right. But pdf wrong. html

vasiliy-komarov commented 7 years ago

Sorry.. I saw later issue but it did not help me. v. 1.5.1

vasiliy-komarov commented 7 years ago

Code now <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta charset="UTF-8"/> <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet"> <title>Title</title> </head> <body> <div class="pdf-content"> <div class="pdf-label">Label</div> <div style="font-family: 'Open Sans';"> ТЕКСТ Russian </div> </div> </body> </html>

pdfGenerator.loadTemporaryFonts(Arrays.asList(new String[]{"fonts/OpenSans-Regular.ttf"}));

marcosinigaglia commented 7 years ago

Thanks.