我可以用jspdf将不同方向的pdf文件组合在一起吗?

问题描述 投票:2回答:1

我想把不同方向的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里。

javascript printing jspdf
1个回答
0
投票

我试过这个api,它的工作原理很好,与 orientation 争论。

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

© www.soinside.com 2019 - 2024. All rights reserved.