PDFKit

Paket

JavaScript library that draws PDF documents from code in Node.js and the browser

Fiyat
Free, open source
Erişim
None, runs locally

Hakkında

MIT-licensed library with a chainable API for building PDFs: wrapped text and lists, embedded fonts and images, vector graphics, tables, links and annotations, AcroForms, encryption and tagged PDF/UA output. It does not render HTML; your code places the content.

Neler yapabilirsin

  • Generate invoices or reports as PDFs from a Node.js server
  • Stream a generated PDF straight into an HTTP response
  • Build fillable PDF forms with AcroForm fields in JavaScript

Başlarken

  1. Install the package with npm install pdfkit
  2. Pipe the document to a file or HTTP response, then call doc.end()

Örnek kod

const { PDFDocument } = require('pdfkit');
const fs = require('fs');

// Create a document
const doc = new PDFDocument();

// Pipe its output somewhere, like to a file or HTTP response
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'
});

// Finalize PDF file
doc.end();

Ayrıntılar

Barındırma
Kendi bilgisayarında
Kullanılabildiği yerler
Tüm dünya
Resmi SDK'lar
JavaScript/TypeScript
MCP sunucusu
Yok

Görevler

Alternatifler

Aynı görevler için başka araçlar.

Son kontrol: .