Tausif Khan
Tausif Khan

Reputation: 1

openhtmltopdf-box hindi font rendering issue in pdf

I have created a two pdf file from html by using two different pdf libraries first is openhtmltopdf-box library second is mpdf library

the content of pdf is hindi and both library created a pdf successfully but the pdf in first library is not rendered properly in pdf but when i copy the same content from that pdf and paste it anywhere the content is render properly

now in second library the content is rendering properly in pdf but when i copy the same content and pasting anywhere it is changed there is a problem in hindi text where two letters or matras are mixed what is the problem here and how to resolve this

below is the content i am showing u

actual text = "वर्तमान" first library is showing some other text but when i copy and paste here then it will become proper

second library text showing proper in pdf but when i copy it and paste here it becomes "वतमान"

I am just comparing my problem with other library, but i am using openhtmltopdf-box library and how to resolve this problem in this library for rendering a content properly in pdf file.

source code :

  public byte[] startPdfCreation(PdfRendererBuilder builder, String template, PdfConfiguration configuration) {
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
  builder.useFastMode();
  Document document = Jsoup.parse(template, "UTF-8");
  builder.withW3cDocument(new W3CDom().fromJsoup(document), "/");
  builder.usePageSupplier(new BackgroundImageHandler(configuration.getLetterheadContent()));
  builder.toStream(os);
  builder.run();
  return os.toByteArray();
} catch (Exception e) {
  log.error("Error while creating a PDF", e);
}
return new byte[0];
}

Upvotes: 0

Views: 71

Answers (0)

Related Questions