我能否使用jspdf将不同方向的pdf文件合并在一起?

4

我希望将不同方向的pdf合并成一个以供打印。

因此,我想知道是否可以使用jspdf来实现。谢谢。

这是我生成一个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();
                        }
                    }
                }

我找到了一个API addPage(format?: string | number[], orientation?: 'p'|'portrait'|'l'|'landscape'): jsPDF;,也许我可以在同一个PDF中放置不同方向的页面。

1个回答

1

我尝试了这个API,使用orientation参数可以正常工作。

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接