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