<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          PDFKit基于Node.js的PDF工具包

          聯(lián)合創(chuàng)作 · 2023-09-23 19:05

          PDFKit 是一個用于Node和瀏覽器的PDF文檔生成庫,可以輕松創(chuàng)建復雜的多頁面可打印文檔。 API包含可鏈接性,包括低級功能以及更高級功能的抽象。 PDFKit API設計簡單,因此生成復雜文檔通常與一些函數(shù)調(diào)用一樣簡單。

          主要特性:

          • Vector graphics
            • HTML5 canvas-like API
            • Path operations
            • SVG path parser for easy path creation
            • Transformations
            • Linear and radial gradients
          • Text
            • Line wrapping
            • Text alignments
            • Bulleted lists
          • Font embedding
            • Supports TrueType (.ttf), OpenType (.otf), WOFF, WOFF2, TrueType Collections (.ttc), and Datafork TrueType (.dfont) fonts
            • Font subsetting
            • See fontkit for more details on advanced glyph layout support.
          • Image embedding
            • Supports JPEG and PNG files (including indexed PNGs, and PNGs with transparency)
          • Annotations
            • Links
            • Notes
            • Highlights
            • Underlines
            • etc.
          • Outlines
          • PDF security
            • Encryption
            • Access privileges (printing, copying, modifying, annotating, form filling, content accessibility, document assembly)

          安裝:npm install pdfkit

          示例代碼:

          const PDFDocument = require('pdfkit');
          
          // Create a document
          const doc = new PDFDocument;
          
          // Pipe its output somewhere, like to a file or HTTP response
          // See below for browser usage
          doc.pipe(fs.createWriteStream('output.pdf'));
          
          // Embed a font, set the font size, and render some text
          doc.font('fonts/PalatinoBold.ttf')
             .fontSize(25)
             .text('Some text with an embedded font!', 100, 100);
          
          // Add an image, constrain it to a given size, and center it vertically and horizontally
          doc.image('path/to/image.png', {
             fit: [250, 300],
             align: 'center',
             valign: 'center'
          });
          
          // Add another page
          doc.addPage()
             .fontSize(25)
             .text('Here is some vector graphics...', 100, 100);
          
          // Draw a triangle
          doc.save()
             .moveTo(100, 150)
             .lineTo(100, 250)
             .lineTo(200, 250)
             .fill("#FF3300");
          
          // Apply some transforms and render an SVG path with the 'even-odd' fill rule
          doc.scale(0.6)
             .translate(470, -380)
             .path('M 250,75 L 323,301 131,161 369,161 177,301 z')
             .fill('red', 'even-odd')
             .restore();
          
          // Add some text with annotations
          doc.addPage()
             .fillColor("blue")
             .text('Here is a link!', 100, 100)
             .underline(100, 100, 160, 27, {color: "#0000FF"})
             .link(100, 100, 160, 27, 'http://google.com/');
          
          // Finalize PDF file
          doc.end();

           

          瀏覽 48
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  大屌狠狠操 | 无码粗大| 女扒尿口色 | 男女舞夜操逼视频一区二区 | 国产精品99久久久久久www |