本文整理汇总了TypeScript中jspdf.addImage函数的典型用法代码示例。如果您正苦于以下问题:TypeScript addImage函数的具体用法?TypeScript addImage怎么用?TypeScript addImage使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了addImage函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
var createPDF = function (imgData:string) {
var doc = new jsPDF();
doc.addImage(imgData, 'JPEG', 10, 10, 50, 50, 'monkey'); // Cache the image using the alias 'monkey'
doc.addImage('monkey', 70, 10, 100, 120); // use the cached 'monkey' image, JPEG is optional regardless
doc.addImage({
imageData: imgData,
angle: -20,
x: 10,
y: 78,
w: 45,
h: 58
});
doc.output('datauri');
};
示例2: function
var createPDF = function (imgData: string) {
var doc = new jsPDF();
doc.addImage(imgData, 'JPEG', 10, 10, 50, 50, 'monkey'); // Cache the image using the alias 'monkey'
doc.addImage('monkey', 70, 10, 100, 120); // use the cached 'monkey' image, JPEG is optional regardless
doc.addImage({
imageData: imgData,
rotation: -20,
x: 10,
y: 78,
width: 45,
height: 58
});
doc.output('datauri', {filename: 'test.pdf'});
};
示例3: formatDate
export const printPayment = (
account: Linode.Account,
payment: Linode.Payment
) => {
try {
const date = formatDate(payment.date, { format: 'YYYY-MM-DD' });
const paymentId = payment.id;
const amount = payment.usd;
const tableEnd = tableBodyStart + cellHeight;
const doc = new jsPDF({
unit: 'px'
});
const addTable = () => {
doc.setFontSize(10);
const header = [
{ name: 'Description', prompt: 'Description', width: 292 },
{ name: 'Date', prompt: 'Date', width: 128 },
{ name: 'Amount', prompt: 'Amount', width: 128 }
] as any[]; // assert type 'any' because per source code this is an extended and more advanced way of usage
const itemRows = [
{
Description: 'Payment. Thank you.', // Automatic line breaks don't work well. Doing it manually
Date: renderDate(date),
Amount: '$' + amount
}
];
doc.table(leftPadding, 140, itemRows, header, {
fontSize: 12,
printHeaders: true,
autoSize: false,
margins: {
left: 15,
top: 10,
width: 800,
bottom: 0
}
});
};
const addTotalAmount = () => {
doc.setFontSize(13);
doc.setFontStyle('bold');
// Empty line
doc.cell(leftPadding, tableEnd, 411, 10, ' ', 1, 'left');
// "Total" cell
doc.cell(
leftPadding,
tableEnd + 10,
374,
20,
'Payment Total: ',
2,
'right'
);
// Total value cell
doc.cell(
leftPadding + 300,
tableEnd + 10,
37,
20,
`$${Number(amount).toFixed(2)}`,
2,
'left'
);
// reset text format
doc.setFontStyle('normal');
};
doc.addImage(LinodeLogo, 'JPEG', 150, 5, 120, 50);
addLeftHeader(doc, 1, 1, date, 'Payment');
addRightHeader(doc, account);
addTitle(doc, `Receipt for Payment #${paymentId}`);
addTable();
addFooter(doc);
addTotalAmount();
doc.save(`payment-${date}.pdf`);
} catch (e) {
console.error(e);
}
};
示例4: test_addImage
function test_addImage() {
var doc = new jsPDF();
doc.addImage({imageData: '/image.png', x: 0, y: 0, width: 100, height: 100});
}