wooio / htmltopdf-java

An HTML to PDF conversion library written in Java, based on wkhtmltopdf.
MIT License
173 stars 97 forks source link

Result PDF lost encoding UTF-8 #31

Closed jcabala14 closed 4 years ago

jcabala14 commented 5 years ago

Hello!

When I try to generate a PDF from directly HTML, PDF lost encoding from HTML. The HTML has the encoding introduced in UTF-8 into head at tag, and into the code with the defaultEncoding method from htmltopdf.

HtmlToPdf.create(
    .object(HtmlToPdfObject.forHtml("<p>Prueba número 1</p>").defaultEncoding("utf-8)).convert();

The encoding used is UTF-8 because the generated pdf is in spanish.

Is an issue? How to keep html encoding in pdf?

Thanks!

benbarkay commented 5 years ago

try adding charset in the document's meta tags:

"<meta charset=\"utf-8\">

Spanish text...

"

On Mon, Aug 26, 2019 at 1:07 PM Jorge Cabal notifications@github.com wrote:

Hello!

When I try to generate a PDF from directly HTML, PDF lost encoding from HTML. The HTML has the encoding introduced in UTF-8 into head at tag, and into the code with the defaultEncoding method from htmltopdf.

HtmlToPdf.create( .object(HtmlToPdfObject.forHtml("

This is the second object...

").defaultEncoding("utf-8)).convert();

The encoding used is UTF-8 because the generated pdf is in spanish.

Is an issue? How to keep html encoding in pdf?

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wooio/htmltopdf-java/issues/31?email_source=notifications&email_token=AA4DXURD7EFXQURE4Z75ZFLQGOTOXA5CNFSM4IPOB2GKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HHK5EZQ, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4DXUWVFFHITSK45BEJEEDQGOTOXANCNFSM4IPOB2GA .

-- בן ברקאי

jcabala14 commented 5 years ago

Hi @benbarkay,

I tryed use this tags:

<meta charset="UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

And both at the same time, but result is the same. Is strictly necesary add backslash at charset like your comment?

Best regards.

benbarkay commented 4 years ago

See #32 if this is still a problem.