Hacker News new | comments | ask | show | jobs | submit login
Show HN: PDF Assembler – client-side PDF editing
25 points by dschnelldavis 9 months ago | hide | past | web | favorite | 11 comments
Here's a neat hack I made recently to do basic PDF editing directly in a browser—without having to upload anything to a server.

I was initially looking for a way to do simple PDF modification (extracting pages, merging, and adding page numbers). There are some good server-side tools for this (QPDF, PDFTk, PDFBox, iText, Hummus), but for better speed and privacy I really wanted a 100% client-side solution.

There are a few good JavaScript PDF libraries for reading and displaying PDFs (pdf.js) and creating PDFs from scratch (jsPDF, PDFKit), but I couldn't find any for editing existing PDFs. So, I did what any self-respecting hacker would do, and rolled my own. :-)

Actually, I found out that Mozilla's pdf.js solved half the problem, as it does an excellent job disassembling PDF files. So all I had to do was figure out a way to put them back together again.

The result is PDF Assembler, now available on GitHub and NPM. I also put together a demonstration site (https://www.pdfcircus.com) which shows some examples of what it can do. I know PDF Assembler still needs some tweaking, but I think the basic idea is sound, and so far I've been pretty happy with how it works.

Please take a look and let me know what you think.


PDF Assembler Links:

Demonstration Site - https://www.pdfcircus.com

GitHub - https://github.com/DevelopingMagic/pdfassembler

NPM - https://www.npmjs.com/package/pdfassembler

Awesome! I will totally use this. Love that I don't need to upload them to some unknown server. Although macOS preview lets you merge PDFs by dragging and dropping, but not more complex editing.

Glad to hear it. If you have any problems, or additional features you'd like to see, please post an issue on GitHub.



I am using a tiling window manager and do not want to pop up dolphin, is there any way to upload a file without dragging?

Not yet. That's been on my to-do list, but I didn't know how important it was. I'll move it to the top of my list and post agin once it's fixed.

Thanks for the feedback!

OK, I've added an "Add PDF" button to open a file select dialog, which should let you load files without drag-and-drop. Please let me know how it works for you.


great. love it.

Minor typo on pdfcircus.com

—wihtout uploading to a server

Fixed. Thank you!

That looks super helpful. Thanks!

> There are some good server-side tools for this (QPDF, PDFTk, PDFBox, iText, Hummus)

Fake news! QPDF[0] can work offline on local PC - just download AppImage and execute it on your Linux desktop!

> but for better speed and privacy I really wanted a 100% client-side solution.

Think, you mean "offline solution", because "client-side solution" is always mean that is part of some "online service".

[0] https://github.com/qpdf/qpdf/releases

Nope, I definitely meant "client-side solution".

I wrote this library to work as part of an online service to help lawyers assemble Exhibits (www.magicexhibits.com).

The first version of that site uploaded everything to a server, where I used QPDF and Hummus to put everything together into a big .pdf, then downloaded the result. It worked, but it was slow.

The second version used an Emscripten encoded version of qpdf[0] to move part of the processing client-side (meaning into the browser), which made the processing faster. But even after compressing as much as possible, the Emscripten qpdf.js was 4mb, which made the site load time much slower.

So, finally, I wrote PDF Assembler, which loads fast and does almost all of what I need. If someone loads a document I can't process with JavaScript alone, like a .docx file, I still have to send that to a server to convert to a .pdf. But PDF Assembler does the majority of the processing right in the browser, which makes the site a LOT faster. And, as a nice side effect, our users like the improved privacy protection, because as long as all their input files are .pdfs, those files never leave their computer.

Personally, I use QPDF on the command line (in OS X) quite a bit, and I've also used PDFTk and Hummus on my local computer. But our users aren't as computer savvy, so it was important to make a solution for them that was as simple as possible - meaning one that didn't involve downloading and installing any software. So an SPA is an ideal solution for them, and an SPA that uploads as little as possible to the server is even better.

[0] https://github.com/jrmuizel/qpdf.js

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact