Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump pako from 1.0.11 to 2.0.3 #863

Closed
wants to merge 385 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
385 commits
Select commit Hold shift + click to select a range
60356f6
Update README.md
Hopding Jul 3, 2019
6fec944
Update README.md
Hopding Jul 3, 2019
41e7fbd
Flesh out README
Hopding Jul 3, 2019
a54e3db
Add fontkit installation instructions
Hopding Jul 3, 2019
1842059
Add PDF links to README
Hopding Jul 3, 2019
163cb25
Formatting
Hopding Jul 3, 2019
8e7503d
Fix README examples
Hopding Jul 4, 2019
63ba75a
Modify example PDF
Hopding Jul 4, 2019
0e11a52
Modify example PDF
Hopding Jul 4, 2019
bc5ecaf
Fix embedded font Subtype bug
Hopding Jul 4, 2019
f814e5e
Fix example PDF
Hopding Jul 4, 2019
0b6ef3a
Update README
Hopding Jul 4, 2019
acbdc4b
Add image embedding example to README
Hopding Jul 4, 2019
ac8cc95
Cleanup README
Hopding Jul 4, 2019
7adfea6
Add comments to examples in README
Hopding Jul 5, 2019
c886a96
Add "encryption handling" section to README
Hopding Jul 5, 2019
66c8e5a
Add license
Hopding Jul 6, 2019
18878dc
Add "Complete Examples" section to README
Hopding Jul 6, 2019
764fb4b
Fix stream parsing bug
Hopding Jul 6, 2019
de72eb8
Fix object stream in Acrobat
Hopding Jul 7, 2019
0b16bb6
Fix page insertion bug
Hopding Jul 7, 2019
bd22757
Cleanup test logs
Hopding Jul 7, 2019
4cffcab
Add CSP to web tests
Hopding Jul 7, 2019
ce12061
Add "files" to package.json
Hopding Jul 7, 2019
7fb3f44
Allow saving to base64/dataUri
Hopding Jul 7, 2019
1e48fab
Add PDFPage.translateContent
Hopding Jul 7, 2019
d123b59
Include digits A-F when decoding hex values in PDFNames
Jul 10, 2019
816acc3
Add apps/rn
Hopding Jul 12, 2019
776a3ab
Fix prepublish script
Hopding Jul 12, 2019
f73a1b7
Optimize RN tests
Hopding Jul 12, 2019
6d47d99
Fix README link
Hopding Jul 12, 2019
8b27500
Add runtime arg validation
Hopding Jul 13, 2019
57dc8a4
Revert change to test
Hopding Jul 13, 2019
14e8645
Docs cleanup
Hopding Jul 20, 2019
b15a91c
Add doc comments
Hopding Jul 21, 2019
54142d4
Add node-fetch for development
Hopding Jul 21, 2019
f975301
Merge branch 'Rewrite' of github.com:Hopding/pdf-lib into Rewrite
Hopding Jul 21, 2019
6b0201c
Fix StandardFonts
Hopding Jul 21, 2019
20bb5ab
Finish documenting PDFPage
Hopding Jul 21, 2019
f1d7883
Finish documenting PDFImage
Hopding Jul 21, 2019
4a46ddb
Finish documenting PDFFont
Hopding Jul 21, 2019
c1d578c
WIP: Document PDFDocument
Hopding Jul 22, 2019
f878b0e
Finish documenting PDFDocument
Hopding Jul 22, 2019
3d0616d
Update README; Add CONTRIBUTING.md
Hopding Jul 23, 2019
bd3588f
Update README.md
Hopding Jul 23, 2019
ec113c7
Flesh out CONTRIBUTING.md
Hopding Jul 23, 2019
896c203
Merge branch 'Rewrite' of github.com:Hopding/pdf-lib into Rewrite
Hopding Jul 23, 2019
534b1ff
Update CONTRIBUTING.md
Hopding Jul 23, 2019
5739247
Add migration guide from v0.x.x to v1.0.0 (#142)
pjm4 Jul 27, 2019
d6bb7f6
Cleanup README
Hopding Jul 27, 2019
8de5b35
Bump lodash from 4.17.11 to 4.17.15 in /apps/rn (#144)
dependabot[bot] Jul 27, 2019
f8bd148
Bump lodash from 4.17.11 to 4.17.15 (#145)
dependabot[bot] Jul 27, 2019
3d08b02
Cleanup
Hopding Jul 27, 2019
c41ce92
Merge branch 'master' of github.com:Hopding/pdf-lib
Hopding Jul 27, 2019
17b4036
Update "homepge"
Hopding Jul 27, 2019
0cba701
Update README.md (#146)
Hopding Jul 27, 2019
44eae4f
Add release scripts
Hopding Jul 28, 2019
d62010a
Merge branch 'master' of github.com:Hopding/pdf-lib
Hopding Jul 28, 2019
269998e
Add release:tag script
Hopding Jul 28, 2019
6738aa2
Fix page count bug (#153)
Hopding Aug 4, 2019
1d4faa7
Fix bug preventing PDFDocument.addPage() on empty documents
Hopding Aug 4, 2019
6b9d811
Bump mixin-deep from 1.3.1 to 1.3.2 (#178)
dependabot[bot] Sep 2, 2019
9a1c0cd
Add PDFName tests (#180)
Hopding Sep 2, 2019
e42f40d
Update dev dependencies (#181)
Hopding Sep 2, 2019
cb0bca1
Update dependencies (#196)
Hopding Sep 23, 2019
bc3fd54
Draw wrapped text (#198)
Hopding Sep 24, 2019
ea425f4
Handle undefined refs when copying (#199)
Hopding Sep 24, 2019
0cf6f52
Handle parsing updated PDFs missing EOL after EOF marker (#200)
Hopding Sep 24, 2019
09ff093
Add PDFPage.drawLine() method (#201)
Hopding Sep 25, 2019
adf0e57
Update versions
Hopding Sep 25, 2019
7e06c40
Add metadata methods to PDFDocument (#204)
Hopding Oct 1, 2019
f7707f1
Add page.drawSVG(path) method (#202)
jlmessenger Oct 4, 2019
5eac02c
Cleanup
Oct 4, 2019
f17521b
Bump version to 1.2.0
Oct 9, 2019
356d335
Add examples to README
Oct 10, 2019
ed1696c
Update README
Oct 10, 2019
43b71cc
Update README
Oct 10, 2019
acb837a
Increase random digits used for image xObjectKey to 10 (#215)
thebenlamm Oct 11, 2019
4a3d795
Include inherited resources when normalizing (#222)
Hopding Oct 19, 2019
885a4c0
Add Possibility to throw error on invalid objects being parsed (#235)
jwoodrow Dec 16, 2019
c576556
Update PDFDocument tests
Dec 16, 2019
7adf4f2
Test stream (#254)
cshenks Dec 16, 2019
8b7304d
Update dependencies
Dec 16, 2019
6391c2f
Update CONTRIBUTING.md
Hopding Dec 16, 2019
3ecd836
Add PDFDocument.setLanguage method
ggrossetie Dec 18, 2019
620747a
Cleanup
Dec 18, 2019
62fe713
Add a note about Windows line endings for contributors (#256)
cshenks Dec 18, 2019
8346da3
Update CONTRIBUTING.md
Hopding Dec 18, 2019
d5aab62
Remove const enum (#276)
Hopding Dec 23, 2019
645a530
Bump version to 1.3.0
Hopding Dec 23, 2019
6ded293
Mention jsDelivr in README
Hopding Dec 24, 2019
4539901
Bump handlebars from 4.1.2 to 4.5.3 (#282)
dependabot[bot] Dec 28, 2019
ae29c09
Bump handlebars from 4.1.2 to 4.5.3 in /apps/rn (#283)
dependabot[bot] Dec 28, 2019
b3e5001
Do not error when document is saved with no pages (#286)
Hopding Dec 28, 2019
2c19a50
Add section to migration guide about createContentStream (#287)
Hopding Dec 28, 2019
0422d9a
Mark some types of files as binary
Hopding Dec 28, 2019
115d7b0
Update line ending config
Hopding Dec 29, 2019
f6aa226
Update line ending config
Hopding Dec 29, 2019
11d86bb
Add JSFiddle demos to README
Hopding Dec 30, 2019
56d9a8e
Merge branch 'master' of github.com:Hopding/pdf-lib
Hopding Dec 30, 2019
3a8bdc8
Fix cmaps (#298)
Hopding Dec 31, 2019
9535e35
Update package.json contributors
Hopding Dec 31, 2019
ac4bb3e
Export decodePDFRawStream (#301)
Hopding Jan 1, 2020
370c435
Update dependencies and rollup plugins (#302)
Hopding Jan 1, 2020
0ac0d04
Fix extra page bug (#303)
Hopding Jan 1, 2020
0578530
Bump version to 1.3.1
Hopding Jan 1, 2020
f5cb023
Update png lib (#361)
Hopding Feb 21, 2020
6b27702
Handle missing comments on binary "line" when parsing (#364)
Hopding Feb 23, 2020
82074c1
Bump version to 1.3.2
Hopding Feb 23, 2020
b52d566
Update README.md
Hopding Feb 26, 2020
9a79a47
Implement embedded PDFs (#348)
tessi Feb 26, 2020
2173190
Update contributors list
Hopding Feb 26, 2020
3f6d8e9
Cleanup and minor refactoring
Hopding Feb 26, 2020
2380f00
Polish up page embedding
Hopding Feb 28, 2020
2f448fb
Add page embedding example to README
Hopding Feb 28, 2020
e16420f
Export PDFEmbeddedPage and Embeddable
Hopding Feb 29, 2020
dd71797
Add downlevel-dts (#368)
Hopding Feb 29, 2020
b693c81
Bump version to 1.4.0
Hopding Feb 29, 2020
1cc4e92
Update JSFiddles
Hopding Feb 29, 2020
0f08198
Update README.md
Hopding Feb 29, 2020
1aa2169
Handle parsing empty dicts with whitespace between brackets (#370)
Hopding Mar 1, 2020
2309012
Fix page deletion bug (#378)
Hopding Mar 7, 2020
1c69b41
Bump version to 1.4.1
Hopding Mar 7, 2020
73b157b
Bump acorn from 5.7.3 to 5.7.4 (#383)
dependabot[bot] Mar 31, 2020
a64eeb3
Bump acorn from 5.7.3 to 5.7.4 in /apps/rn (#394)
dependabot[bot] Mar 31, 2020
3c15aa5
Update README.md (#384)
ajmeese7 Apr 2, 2020
1268907
Update dependencies (#403)
Hopding Apr 10, 2020
5df411f
Bump acorn from 6.1.1 to 6.4.1 (#404)
dependabot[bot] Apr 10, 2020
129b846
Enhance PDFPage set/get height (#405)
Hopding Apr 12, 2020
ac74e89
Add PDFObject accessors (#414)
Hopding Apr 18, 2020
350c54b
Read metadata fields (#423)
Hopding Apr 25, 2020
594fc6a
Fix embedded CMYK image (#415)
zwaldowski Apr 26, 2020
a5fca79
Fixups (#426)
Hopding Apr 26, 2020
095c3e7
Update dependencies (#427)
Hopding Apr 26, 2020
e1fccea
Bump version to 1.5.0
Hopding Apr 26, 2020
3c11ddf
Add JSFiddle example to README
Hopding Apr 26, 2020
fc66fd9
Handle non ASCII characters in PDF name objects (#429)
Hopding Apr 29, 2020
34ae0d0
Fix page removal bug (#441)
Hopding May 9, 2020
9e8678c
Feature/draw line cap style (#437)
taxilian May 9, 2020
da94204
Add PDFPage.drawText.lineCap to tests
Hopding May 9, 2020
7520bd2
Bump version to 1.6.0
Hopding May 16, 2020
99a21a3
Support Deno (#448)
Hopding May 17, 2020
dedfaa8
Update README.md
Hopding May 17, 2020
216d9e7
Cap parsed numbers at Number.MAX_SAFE_INTEGER (#458)
Hopding May 24, 2020
3256473
Make lineCap prop optional (#460)
Hopding May 25, 2020
13ed2ef
Add PDFDocument.load.capNumbers option (#461)
Hopding May 25, 2020
e32be89
Bump version to 1.6.1
Hopding May 25, 2020
b7df617
Embed files (#455)
sebastinez May 26, 2020
f0fccbe
Polish attachments code
Hopding May 29, 2020
dd32d28
Update attachment tests
Hopding May 30, 2020
c47aae6
Bump version to 1.7.0
Hopding May 30, 2020
9b6fb96
Add attachments JSFiddle
Hopding May 30, 2020
238f5f4
Opacity - semi transparent objects (#487)
soadzoor Jun 17, 2020
ef64970
Run prettier
Hopding Jun 17, 2020
22b99a6
Refactor opacity code
Hopding Jun 18, 2020
2c3c4be
Remove indirect objects with objectNumber=0 after parsing (#496)
Hopding Jun 20, 2020
28722e1
Update dependencies (#497)
Hopding Jun 20, 2020
6bb3a5a
Bump version to 1.8.0
Hopding Jun 20, 2020
219a01b
Fix doc comment indentation
Hopding Jun 20, 2020
556c73c
Fix doc comment indentation
Hopding Jun 20, 2020
c2dc5cb
Fix for #483 - Semi-transparent PNG rendered opaque in PDF (#502)
soadzoor Jun 23, 2020
3d321fe
Cleanup
Hopding Jun 23, 2020
ff447a9
Fix dev experience Windows issues
Hopding Jun 23, 2020
ceaa215
Add blendMode options (#503)
bockoblur Jun 24, 2020
f45f194
Cleanup
Hopding Jun 25, 2020
e930e98
Added highlevel ability to provide dashArray and dashPhase (#498)
soadzoor Jun 25, 2020
58be236
Fix import mistake
Hopding Jun 25, 2020
bc4b172
Merge branch 'master' of github.com:Hopding/pdf-lib
Hopding Jun 25, 2020
435bddf
Added highlevel ability to provide lineCap style (#499)
soadzoor Jun 26, 2020
1aa8f09
Cleanup
Hopding Jun 26, 2020
9862898
Bump version to 1.9.0
Hopding Jun 26, 2020
f472c0a
Add link to Discord server in README
Hopding Jun 27, 2020
c477031
Rotation for ellipse and svgPath (#511)
soadzoor Jul 15, 2020
a118cd4
Cleanup
Hopding Jul 15, 2020
d7f2696
Bump lodash from 4.17.15 to 4.17.19 (#533)
dependabot[bot] Aug 2, 2020
556d597
Bump lodash from 4.17.15 to 4.17.19 in /apps/rn (#535)
dependabot[bot] Aug 2, 2020
b033e0f
Fix breaking change to PDFPage.drawEllipse() (#547)
Hopding Aug 2, 2020
9090b9c
Allow custom font name on embed (#543)
ztoben Aug 6, 2020
8b4eabe
Add apps:node to clean script
Hopding Aug 8, 2020
50b9175
Fix circular dependency
Hopding Aug 8, 2020
6ac676a
Bump version to 1.10.0
Hopding Aug 8, 2020
581d87e
Support AcroForm Creation, Filling, and Reading (#599)
Hopding Sep 13, 2020
aa457ba
Bump version to 1.11.0
Hopding Sep 13, 2020
95adc0f
Add form jsfiddles
Hopding Sep 14, 2020
dfe7c47
Make new widgets printable (#604)
Hopding Sep 15, 2020
4046f3c
Bump version to 1.11.1
Hopding Sep 15, 2020
11fe35c
Fix null dict entries (#608)
Hopding Sep 18, 2020
193e48f
Update README.md
Hopding Sep 22, 2020
b1891d4
Return false for PDFSignature.needsAppearancesUpdate (#626)
Hopding Oct 9, 2020
b4d9731
Bump node-fetch from 2.6.0 to 2.6.1 (#598)
dependabot[bot] Oct 9, 2020
f811487
Update references to Pika - must reference new name "Skypack" (#621)
zackdotcomputer Oct 9, 2020
cbe804a
Bump version to 1.11.2
Hopding Oct 9, 2020
30d2aa2
Add PDFDocument.addJavaScript method (#654)
Hopding Oct 31, 2020
cb1c20c
Bump version to 1.12.0
Hopding Nov 15, 2020
f8ef124
Additional support for factur-x (PDF-A3) (#508)
DkDavid Nov 29, 2020
7606de2
Merge branch 'master' of github.com:Hopding/pdf-lib
Hopding Nov 29, 2020
d15b0cb
Add AFRelationship to tests
Hopding Nov 29, 2020
d197ac6
Support Hex String Default Appearances (#693)
Hopding Dec 6, 2020
0d35886
Handle negative bounds (#687)
btecu Dec 6, 2020
1f63950
Bump version to 1.13.0
Hopding Dec 6, 2020
549c1dd
Update package.json contributors
Hopding Dec 6, 2020
cc01872
Font features (#704)
Hopding Dec 13, 2020
f7dfd87
Bump ini from 1.3.5 to 1.3.7 in /apps/rn (#702)
dependabot[bot] Dec 13, 2020
7488595
Expose widget page reference (#695)
btecu Dec 13, 2020
7de691b
Do not add border when none is defined or set to transparent (#696)
btecu Dec 13, 2020
47d9d8b
Add image stamping for TextField elements (#718)
Hopding Dec 20, 2020
b169e2f
Add option to show document's title in window's title bar (#719)
Hopding Dec 20, 2020
b8b5e92
Form Flatten (#716)
btecu Dec 21, 2020
0b83638
Add form flattening to README
Hopding Dec 21, 2020
c957768
Bump version to 1.14.0
Hopding Dec 21, 2020
654334b
Add JSFiddle to README
Hopding Dec 21, 2020
63c6211
Check all radio buttons in a group when deciding if the appearance ne…
btecu Dec 29, 2020
2b4ee6b
Bump version to 1.14.1
Hopding Dec 30, 2020
ebe7421
Support hidden form fields
jbeuckm Jan 2, 2021
8c9d745
Update README.md
Hopding Jan 2, 2021
7e62cba
adding docs for embedding with subset
Jan 2, 2021
5a34d5f
refactoring
Jan 2, 2021
5c4d439
removing extra space
Jan 2, 2021
9f81654
test hidden flag
jbeuckm Jan 3, 2021
252b71b
support hidden in more field types
jbeuckm Jan 3, 2021
808c9fc
optional chaining
jbeuckm Jan 3, 2021
9bf1af1
Fallback to finding the page using the reference (#723)
btecu Jan 5, 2021
b4d8f4e
Update node test18
Hopding Jan 5, 2021
6480405
Update deno test18
Hopding Jan 5, 2021
cccd674
Update web test18
Hopding Jan 5, 2021
4872046
Update rn test18
Hopding Jan 5, 2021
0eda760
Merge pull request #732 from Hopding/723-cleanup
Hopding Jan 5, 2021
1f6751d
Rotate in place when flattening
btecu Jan 5, 2021
009f78a
Merge pull request #734 from btecu/flatten
Hopding Jan 9, 2021
cb1a4df
Merge pull request #730 from jbeuckm/support-hidden-form-fields
Hopding Jan 9, 2021
6343faf
Merge pull request #731 from vlio20/master
Hopding Jan 9, 2021
d1396c7
Cleanup
Hopding Jan 9, 2021
9123576
Merge pull request #741 from Hopding/731-cleanup
Hopding Jan 9, 2021
0ad84c2
Update README.md
lucashmorais Jan 9, 2021
8f33fc7
Merge pull request #742 from lucashmorais/master
Hopding Jan 9, 2021
7168c34
Ensure RadioGroups and CheckBoxes have APs (#743)
Hopding Jan 9, 2021
4be96eb
Bump version to 1.15.0
Hopding Jan 9, 2021
0813ccb
more ViewerPreferences (#745)
mcshaz Jan 24, 2021
a073759
Cleanup #745
Hopding Jan 25, 2021
f5e324b
Merge pull request #769 from Hopding/cleanup-745
Hopding Jan 25, 2021
e3ca413
Cleanup all annotations (#750)
btecu Jan 25, 2021
6e26b6c
Update tests
Hopding Jan 25, 2021
4ddf6e1
Merge conflicts
Hopding Jan 25, 2021
fe92931
Merge pull request #770 from Hopding/cleanup-750
Hopding Jan 25, 2021
674da62
Cleanup 754a (#776)
Hopding Jan 27, 2021
f6a8ce1
Cleanup #754
Hopding Jan 27, 2021
e7a0970
Merge pull request #777 from Hopding/cleanup-754b
Hopding Jan 27, 2021
51bd962
Bump version to 1.16.0
Hopding Jan 27, 2021
d213f92
Ignore undocumented ViewerPreferences fields
Hopding Jan 27, 2021
14935b8
Update package.json
ElectroluxV2 Apr 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 1 addition & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ jobs:
# specify the version you desire here
- image: circleci/node:11.4.0

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4

working_directory: ~/repo

steps:
Expand All @@ -22,9 +17,7 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- v1-dependencies-{{ checksum "package.json" }}

- run: yarn install

Expand Down
16 changes: 16 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
* text eol=lf

tests/**/*.encoded binary eol=lf
tests/**/*.decoded binary eol=lf

*.otf binary
*.ttf binary
*.woff binary
*.woff2 binary
*.pdf binary
*.png binary
*.jpg binary
*.eot binary
assets/**/* binary
*.jar binary
*.bat binary
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
scratchpad/build/
apps/node-build/
node_modules/
coverage/
ts3.4/
build/
dist/
cjs/
es/

tsBuildInfo.json
tsBuildInfo.json
flamegraph.html
yarn-error.log
isolate*.log
.DS_Store
out.pdf
*.tgz

.vscode/settings.json
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/scratchpad/build/scratchpad/index.js",
"outFiles": ["${workspaceFolder}/**/*.js"]
}
]
}
244 changes: 244 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
# Contributing to `pdf-lib`

:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:

`pdf-lib` is a JavaScript library designed to create and modify PDF files in any JavaScript environment. We welcome contributions from the open source community! Please read through this document to learn how to setup and run the project on your machine. If you have any questions or run into trouble, please [create an issue](https://github.com/Hopding/pdf-lib/issues/new).

### Table Of Contents

- [Local Setup and Prerequisites](#local-setup-and-prerequisites)
- [Running the Unit Tests](#running-the-unit-tests)
- [Running the Integration Tests](#running-the-integration-tests)
- [Using the Scratchpad](#using-the-scratchpad)
- [Using the VSCode Debugger](#using-the-vscode-debugger)
- [Generating a Flamegraph](#generating-a-flamegraph)
- [Compiling the Project](#compiling-the-project)
- [Running the Linter](#running-the-linter)
- [Running the Type Checker](#running-the-type-checker)
- [Debugging Tips](#debugging-tips)

## Local Setup And Prerequisites

You can develop `pdf-lib` on Windows, Mac, or Linux machines. While most of the original code was developed on Macs, care has been taken to ensure that all scripts and commands needed for development are platform independent. (If you find anything that doesn't work on your machine/platform, please [create an issue](https://github.com/Hopding/pdf-lib/issues/new) or submit a PR!)

In order to work on `pdf-lib`, please ensure you have installed the following:

- **Node.js** provides the runtime needed to run this project. ([Installation instructions](https://nodejs.org/en/download/) - need `v9.0.0` or greater).
- **Yarn** is the package manager used for this project. ([Installation instructions](https://yarnpkg.com/en/docs/install) - need `v1.12.0` or greater).
- **Git** is the SCM used for this project. ([Installation instructions](https://git-scm.com/downloads) - need `2.17.2` or greater)

Next you'll need to clone the project:

```
git clone https://github.com/Hopding/pdf-lib.git
cd pdf-lib
```

After cloning the project, you'll need to install the dependencies. All dependencies are managed within the `package.json` file. This means all you have to do is run:

```
yarn install
```

If you don't see any errors or warnings, then everything should have worked correctly. The next thing you'll want to do is [run the unit tests](#running-the-unit-tests) to verify that everything is is good shape.

## Running the Unit Tests

We use the [Jest](https://jestjs.io/) framework to write unit tests for `pdf-lib`. All unit tests are kept in the [`tests`](./tests) directory.

To run the unit tests, execute the following:

```
yarn test
```

This should output something like:

```
yarn run v1.16.0
$ jest --config jest.json --runInBand
PASS tests/api/PDFDocument.spec.ts (13.238s)
PASS tests/core/parser/PDFObjectParser.spec.ts
PASS tests/core/parser/PDFParser.spec.ts
...
PASS tests/core/document/PDFTrailer.spec.ts
PASS tests/core/streams/AsciiHexStream.spec.ts

Test Suites: 44 passed, 44 total
Tests: 380 passed, 380 total
Snapshots: 0 total
Time: 22.975s, estimated 39s
Ran all test suites.
✨ Done in 23.66s.
```

Hopefully you see that all the tests passed! But if you see errors or warnings, then something must be wrong with your setup. Please ensure you've following the installation steps outlined in the [local setup and prerequisites section](#local-setup-and-prerequisites). If you still can't get the tests running after following these steps, then please [create an issue](https://github.com/Hopding/pdf-lib/issues/new) explaining the problem you're having.

## Running the Integration Tests

In addition to unit tests, we maintain a suite of integration tests for 3 different JavaScript environments. All integration tests are kept in the [`apps/`](./apps) directory. The goal of these tests is to ensure the project as a whole works correctly, whereas the unit tests ensure individual classes and functions work correctly. The integration tests take longer to run than the unit tests. They also require manual inspection of the PDFs they create to make sure nothing is broken, whereas the unit tests are entirely automatic (they pass/fail without human input).

> **Make sure to [compile the code](#compiling-the-project) before running these tests**

There are integration tests for Node, Deno, browser, and React Native environments:

- To run the tests for Node:
```
yarn apps:node
# Follow the prompts in your terminal
```
- To run the tests for Deno:
```
yarn apps:deno
# Follow the prompts in your terminal
```
- To run the tests for the browser:
```
yarn apps:web
# Open http://localhost:8080/apps/web/test1.html in your browser
```
- To run the tests for React Native (iOS):
```
yarn apps:rn:ios
# Tap through the tests in your simulator
```
- To run the tests for React Native (Android):
```
yarn apps:rn:android
adb reverse tcp:8080 tcp:8080
# Tap through the tests in your simulator
```

## Using the Scratchpad

The scratchpad is a handy tool for testing your code changes. It serves as an entrypoint to the code contained in [`src/`](./src). There are two steps required to use the scratchpad:

1. Start the TypeScript compiler:
```
yarn scratchpad:start
```
Note that you must leave this server running. It will detect code changes
as you make them and automatically recompile the code.
2. Run the [`scratchpad/index.ts`](./scratchpad/index.ts) file:
```
yarn scratchpad:run
```
This will compile and execute the code in your scratchpad file. If you
(1) create a PDF in the scratchpad, (2) save it to the file system, and (3) pass its file path to [`openPdf`](./scratchpad/open.ts#L11) function, then running this command will automatically open the file in your viewer of choice.

## Using the VSCode Debugger

You can use the VSCode debugger to run your scratchpad file. This can be a very powerful tool for testing and debugging the code. There are two steps required to use the debugger:

1. Start the TypeScript compiler:
```
yarn scratchpad:start
```
Note that you must leave this server running. It will detect code changes
as you make them and automatically recompile the code.
2. Run the [`scratchpad/index.ts`](./scratchpad/index.ts) file in the debugger
by clicking the `Start Debugging` button (or use the `F5` keyboard
shortcut).

## Generating a Flamegraph

Flamegraphs are incredibly useful visual tools for troubleshooting performance issues. You can generate a flamegraph using the [scratchpad file](#using-the-scratchpad) as an entrypoint by running `yarn scratchpad:flame` (note that you must have the TypeScript compiler running, as explained above). This will run the scratchpad file, generate a flamegraph of its execution, and automatically open it in your browser.

## Compiling the Project

For most development, manual compilation isn't necessary. The scratchpad and unit tests are usually all you need to test your code changes. But manual compilation _is_ necessary prior to running the integration tests or releasing a new version of the code to NPM.

Compiling the project will produce 4 artifacts:

- **`compiled/cjs`** - a directory containing a CommonJS version of the project (uses `require` instead of `import`). This folder contains `.js` and [`.d.ts`](https://stackoverflow.com/a/21247316) files, rather than the `.ts` files that the project source is written in.
- **`compiled/es`** - a directory containing an ES2015 version of the project (uses `import` instead of `require`). This folder contains `.js` and [`.d.ts`](https://stackoverflow.com/a/21247316) files, rather than the `.ts` files that the project source is written in.
- **`compiled/dist/pdf-lib.js`** - a single JavaScript file containing a [UMD](https://www.davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/) version of the project.
- **`compiled/dist/pdf-lib.min.js`** - a single JavaScript file containing a minified [UMD](https://www.davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/) version of the project.

To compile the project, execute the following:

```
yarn build
```

This should output something like the following:

```
yarn run v1.16.0
$ yarn build:cjs && yarn build:es && yarn build:umd && yarn build:umd:min
$ ttsc --module commonjs --outDir cjs
$ ttsc --module ES2015 --outDir es
$ rollup --config rollup.config.js --file dist/pdf-lib.js

es/index.js → dist/pdf-lib.js...
created dist/pdf-lib.js in 1.5s
$ rollup --config rollup.config.js --file dist/pdf-lib.min.js --environment MINIFY

es/index.js → dist/pdf-lib.min.js...
created dist/pdf-lib.min.js in 4s
✨ Done in 17.34s.
```

The compiled artifacts will be located in the `cjs/`, `es/`, and `dist/` directories.

## Running the Linter

We use two linters to keep `pdf-lib`'s source code clean, tidy, and consistent:

- [**TSLint**](https://palantir.github.io/tslint/)
- [**Prettier**](https://prettier.io/)

It is recommended that you setup your editor to automatically run these linters for you (either on save, or some other keyboard shortcut). However, this is not required. The linters can be run from the command line as well.

To run the linter, execute the following:

```
yarn lint
```

This should output something like the following:

```
yarn run v1.16.0
$ yarn lint:prettier && yarn lint:tslint:src && yarn lint:tslint:tests
$ prettier --write './{src,tests}/**/*.{ts,js,json}' --loglevel error
$ tslint --project tsconfig.json --fix
$ tslint --project tests/tsconfig.json --fix
✨ Done in 7.89s.
```

The linter is very strict about the format and style of your code. Anytime it finds something that doesn't comply with the project's formatting and style standards, it will try to automatically rewrite the file to comply. Note that not all linter errors can be fixed automatically. You will have to manually fix those that can't.

## Running the Type Checker

`pdf-lib` is written in TypeScript. This means that the project's source code is contained in `.ts` files. All source code must be correctly typed in order for the tests to run, and for the project to compile.

To run the type checker, execute the following:

```
yarn typecheck
```

This should output something like the following:

```
yarn run v1.16.0
$ tsc --noEmit
✨ Done in 1.38s.
```

This means your code is correctly typed. If the command fails, then your code has incorrect or missing types somewhere.

## Debugging Tips

Oftentimes when dealing with object offsets and cross references tables/streams, you'll have to deal with byte offsets within a file. The following command can be used (on Linux and Mac machines) to view a given number of bytes at a particular offset:

```bash
cat foo.pdf | tail -c +OFFSET | head -c NUM_BYTES
```

For example, to view the first 100 bytes following the offset 560477 (aka the byte range 560477-560577), you can run:

```bash
cat foo.pdf | tail -c +560477 | head -c 100
```
1 change: 0 additions & 1 deletion GUIDELINES.md

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Andrew Dillon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading