本文整理匯總了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");
}