Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freezing the page in Firefox #155

Open
hamedhafeznia opened this issue Dec 11, 2022 · 1 comment
Open

Freezing the page in Firefox #155

hamedhafeznia opened this issue Dec 11, 2022 · 1 comment
Assignees

Comments

@hamedhafeznia
Copy link

hamedhafeznia commented Dec 11, 2022

Describing the bug:
I'm having a problem using this library in Firefox, when I click the Export Button, the page freezes and does not download the PDF file. I also receive the following error message. happens when there are too many elements on the page.

here's my code:

   <button @click="exportToPDF">Export</button>

    <vue-html2pdf
      ref="html2Pdf"
      :show-layout="false"
      :float-layout="true"
      :enable-download="true"
      :paginate-elements-by-height="1400"
      :pdf-quality="2"
      pdf-format="a2"
      pdf-content-width="500"
      pdf-orientation="landscape">
      <template slot="pdf-content">
        <div id="row-fixed"> CONTENT </div>
        <div id="students-table"> CONTENT </div>
      </template>
    </vue-html2pdf>

Method for downloading the file:
exportToPDF() { this.$refs.html2Pdf.generatePdf(); },

Error:

Uncaught (in promise) Exception { name: "NS_ERROR_FAILURE", message: "", result: 2147500037,
columnNumber: 0
data: null
filename: "/app/_nuxt/c9fb7d694eca1709a462.js"
lineNumber: 2
message: ""
​}

Package Version: 1.8.0

Additional context:
Just happens in Firefox and works well on Chrome.
One thing that I realized is the following element covers the page so the result is freezing the page:

<div class="html2pdf__overlay" style="position: fixed; overflow: hidden; z-index: 1000; inset: 0px; background-color: rgba(0, 0, 0, 0.8); opacity: 0;">
<div class="html2pdf__container" style="position: absolute; width: 23.3858in; left: 0px; right: 0px; top: 0px; height: auto; margin: auto; background-color: white;">
<section data-v-1fd3ad26="" class="content-wrapper">
CONTENT
</section>
</div>
<div>
</div>
@AmirHo3sein
Copy link

In my case, the issue happened because of the 'html2canvas' scale option. If that option has a value above 1.2, Firefox freezes and does not download the PDF.
in beforeDownload function i did this

if (navigator.userAgent.indexOf("Firefox") != -1) { options.html2canvas.scale = 1.2 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants