
Show HN: PDF Assembler – client-side PDF editing - dschnelldavis
Here&#x27;s a neat hack I made recently to do basic PDF editing directly in a browser—without having to upload anything to a server.<p>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.<p>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&#x27;t find any for editing existing PDFs. So, I did what any self-respecting hacker would do, and rolled my own. :-)<p>Actually, I found out that Mozilla&#x27;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.<p>The result is PDF Assembler, now available on GitHub and NPM. I also put together a demonstration site (<a href="https:&#x2F;&#x2F;www.pdfcircus.com" rel="nofollow">https:&#x2F;&#x2F;www.pdfcircus.com</a>) 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&#x27;ve been pretty happy with how it works.<p>Please take a look and let me know what you think.<p>Thanks!<p>PDF Assembler Links:<p>Demonstration Site - <a href="https:&#x2F;&#x2F;www.pdfcircus.com" rel="nofollow">https:&#x2F;&#x2F;www.pdfcircus.com</a><p>GitHub - <a href="https:&#x2F;&#x2F;github.com&#x2F;DevelopingMagic&#x2F;pdfassembler" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DevelopingMagic&#x2F;pdfassembler</a><p>NPM - <a href="https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;pdfassembler" rel="nofollow">https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;pdfassembler</a>
======
timwis
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.

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

[https://github.com/developingMagic/pdfassembler/issues](https://github.com/developingMagic/pdfassembler/issues)

Thanks!

------
geekodour
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?

~~~
dschnelldavis
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!

~~~
dschnelldavis
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.

Thanks.

~~~
geekodour
great. love it.

------
hbcondo714
Minor typo on pdfcircus.com

—wihtout uploading to a server

~~~
dschnelldavis
Fixed. Thank you!

------
matt_the_bass
That looks super helpful. Thanks!

------
app4soft
> _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](https://github.com/qpdf/qpdf/releases)

~~~
dschnelldavis
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](https://github.com/jrmuizel/qpdf.js)

