當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript jspdf.addImage函數代碼示例

本文整理匯總了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');
 };
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:14,代碼來源:jspdf-tests.ts

示例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'});
 };
開發者ID:MrRio,項目名稱:jsPDF,代碼行數:14,代碼來源:jspdf-tests.ts

示例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);
  }
};
開發者ID:displague,項目名稱:manager,代碼行數:85,代碼來源:PdfGenerator.ts

示例4: test_addImage

function test_addImage() {
    
    var doc = new jsPDF();  
    doc.addImage({imageData: '/image.png', x: 0, y: 0, width: 100, height: 100});
}
開發者ID:MrRio,項目名稱:jsPDF,代碼行數:5,代碼來源:jspdf-tests.ts


注:本文中的jspdf.addImage函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。