本文整理汇总了TypeScript中jspdf.setFont函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setFont函数的具体用法?TypeScript setFont怎么用?TypeScript setFont使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setFont函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: addLine
const addLeftHeader = (
doc: jsPDF,
page: number,
pages: number,
date: string | null,
type: string
) => {
const addLine = (text: string, fontSize = 9) => {
doc.text(text, leftPadding, currentLine, { charSpace: 0.75 });
currentLine += fontSize;
};
let currentLine = 55;
doc.setFontSize(9);
doc.setFont(baseFont);
addLine(`Page ${page} of ${pages}`);
if (date) {
addLine(`${type} Date: ${date}`);
}
doc.setFontStyle('bold');
addLine('Remit to:');
doc.setFontStyle('normal');
addLine(`Linode, LLC`);
addLine('249 Arch St.');
addLine('Philadelphia, PA 19106');
addLine('USA');
};
示例2: test_font_types
function test_font_types() {
var doc = new jsPDF();
doc.text(20, 20, 'This is the default font.');
doc.setFont("courier");
doc.text(20, 30, 'This is courier normal.');
doc.setFont("times");
doc.setFontType("italic");
doc.text(20, 40, 'This is times italic.');
doc.setFont("helvetica");
doc.setFontType("bold");
doc.text(20, 50, 'This is helvetica bold.');
doc.setFont("courier");
doc.setFontType("bolditalic");
doc.text(20, 60, 'This is courier bolditalic.');
doc.save('Test.pdf');
}
示例3: test_split_text_to_size
function test_split_text_to_size() {
var doc = new jsPDF();
doc.setFont("Courier");
doc.getTextWidth("Lorem Ipsum");
doc.getStringUnitWidth("Lorem Ipsum");
doc.getCharWidthsArray("Lorem Ipsum");
doc.splitTextToSize("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.", 100);
}
示例4: test_font_metrics_based_line_sizing_split
function test_font_metrics_based_line_sizing_split() {
var pdf = new jsPDF('p', 'in', 'letter');
var sizes:number[] = [12, 16, 20];
var fonts = [['Times', 'Roman'], ['Helvetica', ''], ['Times', 'Italic']];
var font:string[];
var size:number;
var lines:any[];
var verticalOffset = 0.5; // inches on a 8.5 x 11 inch sheet.
var loremipsum = 'Lorem ipsum dolor sit amet, ...';
for (var i in fonts) {
if (fonts.hasOwnProperty(i)) {
font = fonts[i];
size = sizes[i];
lines = pdf.setFont(font[0], font[1])
.setFontSize(size)
.splitTextToSize(loremipsum, 7.5);
pdf.text(0.5, verticalOffset + size / 72, lines);
verticalOffset += (lines.length + 0.5) * size / 72
}
}
pdf.save('Test.pdf');
}
示例5: test_font
function test_font() {
var doc = new jsPDF();
doc.text('This is the default font.',20, 20);
doc.setFont("courier");
}