PDF-LIB
pdf-lib.js.org
PDF-LIB · Create and modify PDF documents in any JavaScript environment.
Create PDF documents from scratch, or modify existing PDF documents. Draw text, images, and vector graphics. Embed your own fonts. Even embed and draw pages from other PDFs. Written in TypeScript and compiled to pure JavaScript with no native dependencies.
npm
npmjs.com › package › pdf-lib
pdf-lib - npm
pdf.js is a PDF rendering library for the Browser. This library was helpful as a reference when writing pdf-lib's parser. Some of the code for stream decoding was ported directly to TypeScript for use in pdf-lib.
» npm install pdf-lib
Published Nov 06, 2021
Version 1.17.1
Author Andrew Dillon
Repository https://github.com/Hopding/pdf-lib
Homepage https://pdf-lib.js.org/
GitHub
github.com › Hopding › pdf-lib › issues › 558
Is the a TypeScript type definition available? · Issue #558 · Hopding/pdf-lib
August 8, 2020 - Something on the order of "@types/pdf-lib". If not, as embarrassed as I am to ask, how can I get VS Code to recognize the types in this excellent library?
Published Aug 08, 2020
PDF-LIB
pdf-lib.js.org › docs › api
pdf-lib · PDF-LIB
OptionListAppearanceProvider : T extends PDFTextField ? TextFieldAppearanceProvider : T extends PDFSignature ?
DEV Community
dev.to › masanori_msl › pdf-lib-electron-typescript-edit-pdf-58hp
[PDF-LIB][Electron][TypeScript] Edit PDF - DEV Community
April 25, 2021 - ... export class ImageEditor { ... public async loadDocument(fileData: Uint8Array): Promise<number> { this.pdfDocument = await pdf.getDocument(fileData).promise; if(this.pdfDocument == null) { console.error('failed loading document'); return 0; } return this.pdfDocument.numPages; } ... ... Programmer, husband, father I love C#, TypeScript, Go, etc.
pdfme
pdfme.com
Free and Open source PDF generation library! | pdfme
Free and Open source PDF generation library fully written in TypeScript, featuring a React-based UI template editor for efficient PDF creation.
npm
npmjs.com › package › @types › react-native-pdf-lib
@types/react-native-pdf-lib - npm
declare let PDFLib: { getDocumentsDirectory(): string; }; export default PDFLib; export class PDFDocument { static create(path: string): PDFDocument; addPages(pages: PDFPage[]): PDFDocument; /* Saves the document and returns the path to the file it wrote */ write(): Promise<string>; } export interface SetMediaBoxOptions { x?: number | undefined; y?: number | undefined; } export interface TextDrawingOptions { x?: number | undefined; y?: number | undefined; color?: string | undefined; fontName?: string | undefined; fontSize?: number | undefined; } export interface RectangleDrawingOptions { x?: n
» npm install @types/react-native-pdf-lib
Published Nov 07, 2023
Version 0.2.3
GitHub
github.com › Hopding › pdf-lib
GitHub - Hopding/pdf-lib: Create and modify PDF documents in any JavaScript environment
pdf.js is a PDF rendering library for the Browser. This library was helpful as a reference when writing pdf-lib's parser. Some of the code for stream decoding was ported directly to TypeScript for use in pdf-lib.
Starred by 8.1K users
Forked by 827 users
Languages TypeScript 80.9% | HTML 9.9% | JavaScript 8.5% | Objective-C 0.3% | CSS 0.2% | Starlark 0.1% | Java 0.1%
CodeSandbox
codesandbox.io › examples › package › pdf-lib
pdf-lib examples - CodeSandbox
@pdf-tools/pdf-web-viewer-samples-vanilla-typescript-activate-deactivate-annotation-modules · apeli23/splintpdf · Find more examples or templates · AboutCreate and modify PDF files with JavaScript1,982,111Weekly Downloads · Latest version1.17.1 · LicenseMIT · External Links · pdf-lib.js.org/ github.com/Hopding/pdf-lib ·
Top answer 1 of 3
8
drawText accepts a maxWidth, when this width is exceeded it will wrap your text! https://pdf-lib.js.org/docs/api/interfaces/pdfpagedrawtextoptions
2 of 3
4
Use maxWidth with wordBreaks. i.e
const text = 'This is a really long bit of text and I want it to remain on the page and resize as needed and not get cut off';
pdfPage.drawText(text, {
x: width / 2 - (text.length * 10),
y: height - 200,
size: 40,
font: pdfFont,
color: rgb(0.95, 0.1, 0.1),
maxWidth: 500, wordBreaks: [" "]
});
GitHub
github.com › Hopding › pdf-lib › issues › 1211
Is there an easy way to get TypeScript Definitions for pdf-lib.min.js to use with Visual Studio? · Issue #1211 · Hopding/pdf-lib
April 10, 2022 - I'm using the pdf-lib.min.js file in my application and I have copied two of the code examples from your website into my application. I had some initial trouble getting it working in Typescript; I was getting an error about PDFLib not found but after a few minutes of web search I added the line:
Published Apr 10, 2022
JSFiddle
jsfiddle.net › Hopding › 64zajhge › 1
Modify Document (pdf-lib) - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
cdnjs
cdnjs.com › home › libraries › pdf-lib
pdf-lib - Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers
Tags: pdf-lib, pdf, document, create, modify, creation, modification, edit, editing, typescript, javascript, library
CodeSandbox
codesandbox.io › s › pdf-lib-2s22c
pdf-lib - CodeSandbox
Published Dec 06, 2019
Repository https://codesandbox.io/s/2s22c
Top answer 1 of 2
7
This is incorrect:
let Document = require('react-pdf');
let Page = require('react-pdf');
You are importing the entire module when you do this. That means that Document and Page both contain all the modules of react-pdf. Instead what you want to do is either import ReactPDF and reference those modules:
const ReactPDF = require('react-pdf');
<ReactPDF.Document />
<ReactPDF.Page />
or you could use destructuring:
import { Document, Page } from 'react-pdf';
//or
const { Document, Page } = require('react-pdf');
If TypeScript complains about missing declarations, just add a @types folder to your project, create a subfolder inside of it called react-pdf and file inside that folder called index.d.ts with one line:
declare module "react-pdf"
2 of 2
3
- first add types
- if you are using create react app you should add:
import { Document, Page, pdfjs } from "react-pdf/dist/esm/entry.webpack";
pdfjs.GlobalWorkerOptions.workerSrc =`//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;