Skip to content

doc.html hangs indefinitely when passing size params on creation #3842

Open
@GeneriicName

Description

@GeneriicName

jspdf version: 2.5.1
enviorment: Chrome, windows 11

sample code:

    async function exportPDF() {
      const editorDiv = await getEditorDiv();
      const outputDiv = await getOutputDivClone();
      const wrapBoth = document.createElement('div');
      wrapBoth.style.backgroundColor = darkModeFlag ? '#1E1E1E' : '#FFFFFF';
      outputDiv.style.backgroundColor = darkModeFlag ? '#1E1E1E' : '#FFFFFF';
      wrapBoth.appendChild(editorDiv);
      wrapBoth.appendChild(outputDiv);
      document.body.appendChild(wrapBoth);
      let doc;
      if (wrapBoth.offsetWidth > wrapBoth.offsetHeight) {
        doc = new jsPDF('l', 'px', [wrapBoth.offsetWidth, wrapBoth.offsetHeight]);
      } else {
        doc = new jsPDF('p', 'px', [wrapBoth.offsetWidth, wrapBoth.offsetHeight]);
      }
      await new Promise(resolve => { doc.html(wrapBoth, { callback: resolve }) });
      wrapBoth.remove();
      doc.save(`${currentTab.name}.pdf`);
    }

it hangs indefinitely on await new Promise(resolve => { doc.html(wrapBoth, { callback: resolve }) });
when i create the new jsPDF with extra parmeters such as page orientation and size units and messures
when i simply create new jsPDF() it works fine (except the size ofc).

in console, the last debug output i get is from html2canvas

#1 0ms Starting document clone with size 1036x260 scrolled to 0,0

html2canvas.min.js:20 [Violation] Avoid using document.write(). https://developers.google.com/web/updates/2016/08/removing-document-write
fn.toIFrame @ html2canvas.min.js:20
(anonymous) @ html2canvas.min.js:20
(anonymous) @ html2canvas.min.js:20
(anonymous) @ html2canvas.min.js:20
(anonymous) @ html2canvas.min.js:20
a @ html2canvas.min.js:20
Js @ html2canvas.min.js:20
(anonymous) @ html2canvas.min.js:20
(anonymous) @ html.js:488
html2canvas.min.js:20 #1 662ms Document cloned, element located at -100000,0 with size 1019x260 using computed rendering
html2canvas.min.js:20 #1 662ms Starting DOM parsing
html2canvas.min.js:20 #1 689ms Starting renderer for element at -100000,0 with size 1019x260
html2canvas.min.js:20 #1 690ms Canvas renderer initialized (1019x260) with scale 1

and after that the whole page just becomes unresponsive and freezes, and i have to close the tab and reopen (relaod wont do it)

without size params, works fine!

any help would be greatly appricated!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions