-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support using PDFKit in the Browser, thanks to Browserify! #223
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
devongovett
added a commit
that referenced
this pull request
Apr 14, 2014
Support using PDFKit in the Browser, thanks to Browserify!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Awesome announcement: PDFKit v0.6 now supports being used in the browser, thanks to Browserify! You can read the documentation in the readme, on the website, and in the PDF guide.
Basically, I did a bunch of work to make PDFKit friendly to browserify, wrote a new zlib module for browserify that is compatibile with Node's API, and wrote a module called blob-stream to take the output of any stream and turn it into an HTML5 Blob object that you can use to view the PDF in the browser directly, trigger a download, or upload to a server.
I also added the ability to use Buffers as a source to the
font
method, just as you can for images. This is especially useful in the browser where you don't have access to a file system. You can load your fonts or images from an HTTP request, or even inline them into your browserify bundle using brfs, and then pass them to PDFKit to get around the lack of a file system in the browser.I will be uploading precompiled versions of PDFKit to Github's releases section from now on, so you can use those if you don't want to use Browserify.
You can see an interactive demo of PDFKit running in the browser here.