0

I tried to export the value of the editor with jsPDF but it doesn't looks pretty. How can I export the value to PDF ?

This is my export method using jsPDF wher val is the html string that the ReactQuill onChange event returns:

export const exportHtmlStr2PDF = async (val, fileName) => {
  let el = document.createElement("div");
  el.style.width = "400px";
  el.style.fontSize = "10px";
  el.style.display = "block";
  el.style.padding = "30px";
  el.innerHTML = val;
  const margins = {
    top: 40,
    bottom: 60,
    left: 40,
    width: 522,
  };

  // const margin = { top: 10, right: 20, bottom: 10, left: 20 };
  var options = {
    margin: [50, 100, 50, 100],
    callback: function (pdf) {
      pdf.save(fileName ? fileName : uuid() + ".pdf");
      el.remove();
    },
  };

  const pdf = new jsPDF("p", "px", "letter");
  pdf.html(el, options);
};

This is the pdf exported:

enter image description here

IOrch-K
  • 23
  • 1
  • 7

0 Answers0