I'm converting HTML to PDF with openhtmltopdf library, but the converted PDF uses "#" instead of characters like "İ","ş","Ş","ç","Ç","Ö". How can I solve it?
Java code:
ByteArrayOutputStream renderedPdfBytes = new ByteArrayOutputStream();
PdfRendererBuilder builder = new PdfRendererBuilder();
builder.withHtmlContent(htmlContent, "/");
builder.toStream(renderedPdfBytes);
builder.run();
renderedPdfBytes.close();
byte[] renderedPdf = renderedPdfBytes.toByteArray();
try (FileOutputStream fos = new FileOutputStream(pdfFile)) {
fos.write(renderedPdf);
}
Html content:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<span class="close-icon close"></span>
<div class="modal-content">
<div class="modal-header"><h2>İade Prosedürü 27.09.2023</h2></div>
<div class="modal-body" style="margin-bottom: 50px;"><p>İade edilmek istenen.</p></div>
</div>
</body>
</html>
HTML View:
Converted PDF View:


If you are experiencing issues with characters not being displayed correctly in the PDF generated using the openhtmltopdf library, it may be related to font embedding or font support. You can modify the code to include custom fonts with proper character support. Here is the example of it.