How to force a new page using jsPDF.html?

Viewed 30

I am using the html method of the jsPDF library to generate a PDF document from an HTML string. The code for the method I use is as follows:

    /**
     * Adds HTML to the document
     * @param {string} html_string
     */
    AddHTML(html_string) {

        try {

            this.doc.html(html_string, {
                callback: function (doc) {
                    doc.save("htmlToDoc.pdf");
                }
            });

        }
        catch (err) {

            console.error(err.message + " in PDFDocument.AddHTML");
        }
    }

(this is a method of my own class PDFDocument - the document itself is created in the constructor and assigned to this.doc).

In the older 'fromHTML' method used in older versions of jsPDF, one could create a new page using the HTML comment

<!-- ADD_PAGE -->

in the HTML string. However, this does not seem to work in the newer method.

I have tried modifying the options passed to the html function by specifying the autoPaging option, trying all of the possible documented values for this (true, false, 'slice', 'text') with no joy.

Does anyone know how to force a new page using this method?

0 Answers
Related