0

I must be convert html elements to PDF, but I don't want to use html2canvas, because this package convert html image at first, then convert to pdf. this way didn't efficient for my needs.

I used latest version of jspdf ( 1.5.3, that said support built in Unicode and utf-8 characters) with jspdf-autotable.

all things worked, except Persian character that corrupted. do I must any setting for Unicode characters in last version of jspdf? I must be use custom font? or default setting built in support Unicode characters?

I read all article about this issue, and run it, but I didn't solve my problem

KoKo
  • 421
  • 1
  • 5
  • 21

1 Answers1

0

Try to use html2pdf library for properly export unicode and Persian/Arabic characters. The html code must be convert to canvas in first step and then convert to pdf.

  function export_to_pdf() {
    // Get the element.
    var element = document.getElementById('root');

    // Generate the PDF.
    html2pdf().from(element).set({
      margin: 0,
      filename: 'test.pdf',
      html2canvas: { scale: 1},
      jsPDF: {orientation: 'portrait', unit: 'in', format: 'a4', compressPDF: true}
    }).save();
  }
Farshad
  • 1,465
  • 1
  • 9
  • 12