Skip to content

NuxtJS: Error: Could not load html2canvas: Error: Cannot find module 'html2canvas' #2867

@KamranMaqbool

Description

@KamranMaqbool

I am trying to use jsPdf in Nuxtjs Application

We have the following code:
import in .vue file
import jsPDF from 'jspdf';

onClick Event for download HTML to pdf
<b-button title="Download" @click="downloadPdf(article.contents)" variant="light" size="sm"> <b-icon icon="file-earmark-arrow-down" variant="primary"></b-icon> </b-button>

in my script section my download function are
downloadPdf(contents) { if (process.browser) { const doc = new jsPDF.default() debugger doc.html(contents, { callback: function(doc) { doc.save(); } }); } },

in My Case contents are HTML string like:
<p>ksdfksd fsd fksd fdfsd</p>

i want to convert HTML String to PDF Document but
Give error in Console are

Uncaught (in promise) Error: Could not load html2canvas: Error: Cannot find module 'html2canvas'
image

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