问题描述
我具有在页面上设置页脚的功能.但是我想使代码更加灵活,并在文档为'a4'或a3'时在其中希望将页脚设置在不同位置的地方添加if语句.
I have a function to set a footer on a page. But I want to make the code more flexible and add an if statement where I want it to set the footer on a different position when the document is an 'a4' or a3'.
function footer(){
doc.setFontSize(11);
doc.text(180,280, 'Seite ' + doc.page);
doc.page ++;
}
但是启动页面后,我找不到用于更改格式的参数:
But I can't find the paramater to change the format after the page has been initiated:
var doc = new jsPDF('p', 'mm', 'a4');
我尝试过:
doc.format('a3');
doc.setFormat = 'a3';
doc.setPageFormat('a3');
但没有效果.
即使在"new jsPDF"启动之后,有人知道在代码中的任何位置更改页面格式的参数吗?还是这根本行不通?
Does someone know the paramater to change page format anywhere in the code even after "new jsPDF" initiation? Or does this simply not work?
提前谢谢!
推荐答案
您可以在每个新页面上设置格式和方向:
You can set format and orientation on each new page:
doc.addPage('a3', 'portrait');
方向是人像"或风景"
Orientation is either 'portrait' or 'landscape'
或者,您也可以设置高度和宽度:
Alternately you can also set the height and widht:
doc.addPage(newWidth, newHeight);
在这种情况下,单位将与您的jsPDF实例化('mm')中的单位相同:
In this case the units will be the same as in your jsPDF instantiation ('mm'):
var doc = new jsPDF('p', 'mm', 'a4');
这篇关于jsPDF更改页面格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!