{"bugs":{"url":"https://github.com/Hopding/pdf-lib/issues"},"dist":{"shasum":"f67beb3e1292e20c9aaae6a0ec81e1c0cf973b05","tarball":"https://registry.npmjs.org/pdf-lib/-/pdf-lib-0.5.0-rc1.tgz","fileCount":457,"integrity":"sha512-I6j+h1hUuVypaRrcne/+QkI/Qg0x7xDU+/I4CBtPPTE9kx660qE3oBpQrWL3kS6MNdKK9Zi6Th3wIoSAo8Fw8A==","signatures":[{"sig":"MEUCIQDsk/IuVFzIlXog1/CxVliYqhTyMn9fa6nFUNegVOmzqQIgBNi2zAnbaPINYBHqUX8hZb08BPS1cWYVBWovJFR9Rr8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3597957,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcFnxOCRA9TVsSAnZWagAAaKUP/jx554JTofp+KuMKxwsT\nNJCq2cm58cxwVGRKoAWnwO4TrToxZQ/uPk6xWdyUuruUnuS2vqwnV6Zhy0lL\nOcxeRdbw7yj/WQUZiJ8q87fbOPDdcK7Dw7cFmv+/t3oTs47JF+g9ZiCp8Ht3\ntElzTH6iciB+OrPWXOn0tuSb5IAXHgCdjIxIuXRlyed7hCa+8RcGWhFVn9I5\nPpMRMkHonTCjoTKneYDDeLuMWcl0j0A3J2VBDFHM1TE5P0sJfcrVj37ddBpe\nG4ytEWu6HM/biq/Pq5vm5v9MqQ+huB3/Zjm+Kz59uZxzxoRjs0uEEYkV5gb8\nin4YxepHrECVraD2w/la80HN0m+G83qy2ir+QQ0j9LgLj+XjkzbDwDuk7Du5\nkvCr1/a2h63qVALYxYH1wMqDcsrtJpYr/Cq7Q95Wb5kSMtGWY0I/8c5QlN4a\nBtcve9bEPLaOl8ksz2pRa9a29W59Oc2+q6YT8rLgGxqLwgg7jrD9Bj9ew1Yn\n0NfPOV6aUFouWWJ5n1jNLPDpDOR5aYUxcS80HR+N5j2wKauwyaf/258Be10q\n/B/Tg94cW/ZJGtrRfOPWh8m3G0lhQqZfudLGrL82z4+5SCdiffi8BysR2uA8\nuPl8oIvydcwYJzRRq7flVbR1lcyeL2zJjl8BbOAxvP3rM8foINiHddHYKSpY\ngzYt\r\n=kdLv\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"globals":{"ts-jest":{"tsConfigFile":"./tsconfig.json"}},"testRegex":"(/__tests__/.*|(\\.|/)(test|spec))$","transform":{"^.+$":"ts-jest"},"collectCoverage":true,"moduleNameMapper":{"^utils":"<rootDir>/src/utils/index.ts","^core/(.*)":"<rootDir>/src/core/$1","^utils/(.*)":"<rootDir>/src/utils/$1"},"collectCoverageFrom":["<rootDir>/src/**/*.ts"],"moduleFileExtensions":["ts","js","json","node"],"testResultsProcessor":"./node_modules/jest-junit","testPathIgnorePatterns":["<rootDir>/integration-tests/","<rootDir>/node_modules/","<rootDir>/__tests__/tsconfig.json","(.*).spec.ts.snap","PDFOperatorSingletonTest.ts"],"coveragePathIgnorePatterns":["<rootDir>/node_modules/","<rootDir>/src/types/"]},"main":"lib/index.js","name":"pdf-lib","types":"lib/index.d.ts","unpkg":"dist/pdf-lib.js","author":{"name":"Andrew Dillon","email":"andrew.dillon.j@gmail.com"},"module":"es/index.js","readme":"<h1 align=\"center\">pdf-lib</h1>\r\n\r\n<div align=\"center\">\r\n  <strong>Create and modify PDF documents in any JavaScript environment.</strong>\r\n</div>\r\n<div align=\"center\">\r\n  Designed to work in any modern JavaScript runtime. Tested in Node, Browser, and React Native environments.\r\n</div>\r\n\r\n<br />\r\n\r\n<div align=\"center\">\r\n  <!-- NPM version -->\r\n  <a href=\"https://www.npmjs.com/package/pdf-lib\">\r\n    <img\r\n      src=\"https://img.shields.io/npm/v/pdf-lib.svg?style=flat-square\"\r\n      alt=\"NPM Version\"\r\n    />\r\n  </a>\r\n  <!-- Build Status -->\r\n  <a href=\"https://circleci.com/gh/Hopding/pdf-lib\">\r\n    <img\r\n      src=\"https://img.shields.io/circleci/project/github/Hopding/pdf-lib/master.svg?style=flat-square&label=CircleCI\"\r\n      alt=\"CircleCI Build Status\"\r\n    />\r\n  </a>\r\n  <!-- Build Status -->\r\n  <a href=\"https://prettier.io/\">\r\n    <img\r\n      src=\"https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square\"\r\n      alt=\"Build Status\"\r\n    />\r\n  </a>\r\n</div>\r\n\r\n<div align=\"center\">\r\n  <h3>\r\n    <a href=\"https://github.com/Hopding/pdf-lib/tree/master/docs\">\r\n      Documentation\r\n    </a>\r\n    <span> | </span>\r\n    <a href=\"https://github.com/Hopding/pdf-lib/tree/master/examples\">\r\n      Examples\r\n    </a>\r\n  </h3>\r\n</div>\r\n\r\n## Table of Contents\r\n* [Motivation](#motivation)\r\n* [Features](#features)\r\n* [Usage Examples](#usage-examples)\r\n  * [Document Creation](#document-creation)\r\n  * [Document Modification](#document-modification)\r\n  * [Copying Pages](#copying-pages)\r\n* [Installation](#installation)\r\n* [API Documentation](#api-documentation)\r\n* [Prior Art](#prior-art)\r\n* [License](#license)\r\n\r\n## Motivation\r\n`pdf-lib` was created to address the JavaScript ecosystem's lack of robust support for PDF manipulation (especially for PDF _modification_).\r\n\r\nTwo of `pdf-lib`'s design requirements since its inception are to:\r\n1. Support modification (editing) of existing documents.\r\n2. Work in all JavaScript environments - not just in Node or the browser.\r\n\r\nThere are other good open source JavaScript PDF libraries available. However, most of them can only _create_ documents, they cannot _modify_ existing ones (e.g. [`pdfkit`](https://github.com/devongovett/pdfkit), [`jspdf`](https://github.com/MrRio/jsPDF), [`pdfmake`](https://github.com/bpampuch/pdfmake)). [`hummus`](https://github.com/galkahana/HummusJS) is a NodeJS library capable of both creating and modifying PDF documents. However, `hummus` is a Node wrapper around a [C++ library](https://github.com/galkahana/PDF-Writer). This means that it cannot run in _all_ JavaScript environments. For example, you cannot use `hummus` in the Browser or in React Native.\r\n\r\n## Features\r\n* Create new PDFs\r\n* Modify existing PDFs\r\n* _**New:**_ [Copy pages between PDFs](#copying-pages)\r\n* Add Pages\r\n* Insert Pages\r\n* Remove Pages\r\n* Draw Text\r\n* Draw Images\r\n* Draw Vector Graphics\r\n* Embed Fonts\r\n* Embed Images\r\n\r\n## Usage Examples\r\nMore detailed examples are available [here](https://github.com/Hopding/pdf-lib/tree/master/examples).\r\n\r\n### Document Creation\r\n```javascript\r\nimport { PDFDocumentFactory, PDFDocumentWriter, drawText } from 'pdf-lib';\r\n\r\nconst pdfDoc = PDFDocumentFactory.create();\r\nconst [timesRomanFont] = pdfDoc.embedStandardFont('Times-Roman');\r\n\r\nconst page = pdfDoc\r\n  .createPage([350, 500])\r\n  .addFontDictionary('Times-Roman', timesRomanFont);\r\n\r\nconst contentStream = pdfDoc.createContentStream(\r\n  drawText('Creating PDFs in JavaScript is awesome!', {\r\n    x: 50,\r\n    y: 450,\r\n    size: 15,\r\n    font: 'Times-Roman',\r\n    colorRgb: [0, 0.53, 0.71],\r\n  }),\r\n);\r\n\r\npage.addContentStreams(pdfDoc.register(contentStream));\r\n\r\npdfDoc.addPage(page);\r\n\r\nconst pdfBytes = PDFDocumentWriter.saveToBytes(pdfDoc);\r\n```\r\n\r\n### Document Modification\r\n```javascript\r\nimport { PDFDocumentFactory, PDFDocumentWriter, drawText } from 'pdf-lib';\r\n\r\n// This should be a Uint8Array.\r\n// This data can be obtained in a number of different ways.\r\n// If your running in a Node environment, you could use fs.readFile().\r\n// In the browser, you could make a fetch() call and use res.arrayBuffer().\r\nconst existingPdfDocBytes = ...\r\n\r\nconst pdfDoc = PDFDocumentFactory.load(existingPdfDocBytes);\r\nconst [helveticaFont] = pdfDoc.embedStandardFont('Helvetica');\r\n\r\nconst pages = pdfDoc.getPages();\r\nconst page  = pages[0];\r\n\r\npage.addFontDictionary('Helvetica', helveticaFont);\r\n\r\nconst contentStream = pdfDoc.createContentStream(\r\n  drawText('This text was added to the PDF with JavaScript!', {\r\n    x: 25,\r\n    y: 25,\r\n    size: 24,\r\n    font: 'Helvetica',\r\n    colorRgb: [0.95, 0.26, 0.21],\r\n  }),\r\n);\r\n\r\npage.addContentStreams(pdfDoc.register(contentStream));\r\n\r\nconst pdfBytes = PDFDocumentWriter.saveToBytes(pdfDoc);\r\n```\r\n\r\n### Copying Pages\r\n```javascript\r\nimport { PDFDocumentFactory, PDFDocumentWriter } from 'pdf-lib';\r\n\r\n// These should be a Uint8Arrays. (see Document Modification example for more details)\r\nconst firstDonorPdfBytes = ...\r\nconst secondDonorPdfBytes = ...\r\n\r\nconst firstDonorPdfDoc = PDFDocumentFactory.load(firstDonorPdfBytes);\r\nconst secondDonorPdfDoc = PDFDocumentFactory.load(secondDonorPdfBytes);\r\n\r\n// We'll copy the fourth page from the first donor document, and the\r\n// first page from the second donor document.\r\nconst firstDonorPage = firstDonorPdfDoc.getPages()[3];\r\nconst secondDonorPage = secondDonorPdfDoc.getPages()[0];\r\n\r\nconst pdfDoc = PDFDocumentFactory.create();\r\n\r\n// Copy over the pages from the donor documents into our new document\r\npdfDoc.addPage(firstDonorPage);\r\npdfDoc.insertPage(0, secondDonorPage);\r\n\r\nconst pdfBytes = PDFDocumentWriter.saveToBytes(pdfDoc);\r\n```\r\n\r\n## Installation\r\n### NPM Module\r\nTo install the latest stable version:\r\n```bash\r\n# With npm\r\nnpm install --save pdf-lib\r\n\r\n# With yarn\r\nyarn add pdf-lib\r\n```\r\nThis assumes you're using [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/lang/en/) as your package manager.\r\n\r\n### UMD Module\r\nYou can also download `pdf-lib` as a UMD module from [unpkg](https://unpkg.com/#/). The UMD builds have been compiled to ES5, so they should work [in any modern browser](https://caniuse.com/#feat=es5). UMD builds are useful if you aren't using a package manager or module bundler. For example, you can use them directly in the `<script>` tag of an HTML page.\r\n\r\nThe following builds are available:\r\n\r\n* https://unpkg.com/pdf-lib/dist/pdf-lib.js\r\n* https://unpkg.com/pdf-lib/dist/pdf-lib.min.js\r\n\r\nWhen using a UMD build, you will have access to a global `window.PDFLib` variable. This variable contains all of the classes and functions exported by `pdf-lib`. For example:\r\n\r\n```javascript\r\n// NPM module\r\nimport { PDFDocumentFactory, drawText } from 'pdf-lib';\r\n\r\n// UMD module\r\nvar PDFDocumentFactory = PDFLib.PDFDocumentFactory;\r\nvar drawText = PDFLib.drawText;\r\n```\r\n\r\n## API Documentation\r\nAPI documentation is available [here](https://github.com/Hopding/pdf-lib/tree/master/docs).\r\n\r\n## Prior Art\r\n* [`pdfkit`](https://github.com/devongovett/pdfkit) is a PDF generation library for Node and the Browser. This library was immensely helpful as a reference and existence proof when creating `pdf-lib`. `pdfkit`'s code for [font embedding](https://github.com/Hopding/pdf-lib/blob/AddDocumentation/src/core/pdf-structures/factories/PDFFontFactory.ts#L64-L68), [PNG embedding](https://github.com/Hopding/pdf-lib/blob/AddDocumentation/src/core/pdf-structures/factories/PNGXObjectFactory.ts#L19-L23), and [JPG embedding](https://github.com/Hopding/pdf-lib/blob/AddDocumentation/src/core/pdf-structures/factories/JPEGXObjectFactory.ts#L32-L36) was especially useful.\r\n* [`jspdf`](https://github.com/MrRio/jsPDF) is a PDF generation library for the browser.\r\n* [`pdfmake`](https://github.com/bpampuch/pdfmake) is a PDF generation library for the browser.\r\n* [`hummus`](https://github.com/galkahana/HummusJS) is a PDF generation and modification library for Node environments. `hummus` is a Node wrapper around a [C++ library](https://github.com/galkahana/PDF-Writer).\r\n* [`react-native-pdf-lib`](https://github.com/Hopding/react-native-pdf-lib) is a PDF generation and modification library for React Native environments. `react-native-pdf-lib` is a wrapper around [C++](https://github.com/galkahana/PDF-Writer) and [Java](https://github.com/TomRoush/PdfBox-Android) libraries.\r\n* [`pdfassembler`](https://github.com/DevelopingMagic/pdfassembler) is a PDF generation and modification library for Node and the browser. It requires some knowledge about the logical structure of PDF document to use.\r\n\r\n## License\r\n[MIT](https://choosealicense.com/licenses/mit/)\r\n","license":"MIT","scripts":{"docs":"rm -rf docs && yarn typedoc --options typedoc.js src/","lint":"yarn prettier --config ./.prettierrc.json --loglevel error --write \"{src,integration-tests,__tests__}/**/*.ts\" && tslint --project ./tsconfig.json --fix","test":"jest --no-coverage --watch","it:node":"ts-node --module commonjs -r tsconfig-paths/register __integration_tests__/runners/node/index.ts","test:ci":"jest --runInBand --no-coverage","test:coverage":"jest","coverage-report":"open coverage/lcov-report/index.html","it:node:profile":"rm isolate*.log && gulp build-dev && node --prof compiled/lib/__integration_tests__/runners/node/index.js && node --prof-process --preprocess -j isolate*.log | flamebearer","jest:clear-cache":"rm -rf $TMPDIR/jest*"},"_npmUser":{"name":"hopding","email":"andrew.dillon.j@gmail.com"},"homepage":"https://github.com/Hopding/pdf-lib#readme","keywords":["pdf-lib","pdf","document","create","modify","creation","modification","edit","editing","typescript","javascript","library"],"jest-junit":{"output":"./coverage/junit.xml"},"repository":{"url":"git+https://github.com/Hopding/pdf-lib.git","type":"git"},"_npmVersion":"5.6.0","description":"Library for creating and modifying PDF files in JavaScript","directories":{},"maintainers":[{"name":"hopding","email":"andrew.dillon.j@gmail.com"}],"_nodeVersion":"9.11.2","dependencies":{"pako":"^1.0.6","buffer":"^5.0.8","lodash":"^4.17.4","png-js":"git+https://github.com/Hopding/png.js.git#9170c1451881487a625fff1cca6de4fd9949cd51","fontkit":"git+https://github.com/Hopding/fontkit.git#97eb4f461e849956a595b3e6c8366cd715f71c38","proxy-polyfill":"^0.3.0"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"del":"^3.0.0","gulp":"^3.9.1","jest":"^22.4.3","chalk":"^2.4.1","faker":"^4.1.0","rollup":"^0.60.7","tslint":"^5.11.0","ts-jest":"^22.4.2","ts-node":"^6.0.5","typedoc":"^0.11.1","inquirer":"^6.0.0","prettier":"^1.15.2","relative":"^3.0.2","jest-junit":"^3.6.0","typescript":"^2.7.2","@types/jest":"^22.2.2","@types/node":"^9.6.0","@types/pako":"^1.0.0","@types/faker":"^4.1.2","gulp-replace":"^1.0.0","@types/lodash":"^4.14.110","tsconfig-paths":"^3.3.2","@types/inquirer":"^0.0.41","gulp-typescript":"^4.0.1","rollup-plugin-uglify":"^4.0.0","rollup-plugin-analyzer":"^2.0.3","rollup-plugin-commonjs":"^9.1.3","tslint-config-prettier":"^1.17.0","typedoc-plugin-markdown":"^1.1.13","rollup-plugin-node-resolve":"^3.3.0"},"_npmOperationalInternal":{"tmp":"tmp/pdf-lib_0.5.0-rc1_1544977485446_0.6823576878722113","host":"s3://npm-registry-packages"},"_id":"pdf-lib@0.5.0-rc1","version":"0.5.0-rc1"}