Could I combine different orientation pdfs together using jspdf?

Viewed 266

I want do combine different orientation pdfs as one for printing stuff.

So I wonder if I could use jspdf to do it. Thanks.

Here is part of my code for generate one pdf:

                let pageHeight = contentWidth / a4WidthPt * a4HeightPt;

                let leftHeight = contentHeight;
                let imgWidth = isLandscape ? 841.89 : 595.28;
                let imgHeight = a4WidthPt / contentWidth * contentHeight;
                var position = 0;
                let pdf = new jsPDF(isLandscape ? 'l' : '', 'pt', 'a4');
                if (leftHeight < pageHeight) {
                    pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight);
                } else {
                    while (leftHeight > 0) {
                        pdf.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight);
                        leftHeight -= pageHeight;
                        position -= a4HeightPt;
                        if (leftHeight > 0) {
                            pdf.addPage();
                        }
                    }
                }

I found a api addPage(format?: string | number[], orientation?: 'p'|'portrait'|'l'|'landscape'): jsPDF;, maybe I could put different orientation page in one pdf.

1 Answers

I tried this api, it works fine with the orientation argument.

addPage(format?: string | number[], orientation?: 'p'|'portrait'|'l'|'landscape'): jsPDF;

Related