Show HN: Simple PDF to PNG Server
secureview.cloudbrowser.xyz
secureview.cloudbrowser.xyz
Edit: in case anyone wants an example, here's the conversion of tesla-model-s.pdf[0]:
https://secureview.cloudbrowser.xyz/uploads/filekat9.v05lnle...
[0]: https://www.tesla.com/sites/default/files/tesla-model-s.pdf
(At the possible cost of top-end scale; improving response to normal workload significantly and hurting the top workload reachable somewhat).
edit: I like the dot ¯\_(ツ)_/¯
Disclaimer: I work for Google Cloud.
It should be too much tho, perhaps just making an install_deps.sh script alternative to use apt, and writing a Dockerfile.
You're welcome to submit a PR but I might get to it first.
Edit: I just made some changes relating to this, including a Dockerfile. I have not tested in Docker, but it now works on Nix (Debian)
The `convert` script of ImageMagick calls soffice by default if the input file is a LibreOffice type.
I actually started writing a shell script to detect if it was DOCX etc, and run soffice first, but then I found out that ImageMagick does that automatically, if libreoffice is installed.
Be interesting to see how your demo site holds up under HN front page traffic - I know Imagemagic is used a lot for random web sites, but I worry about scale a lot. Any info would be useful!
Input looks a bit weird, for example,
https://secureview.cloudbrowser.xyz/uploads/file1tda.4paa65d...
Which is from:
https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/AJ_Dig...
Here's that Tesla example link again:
https://secureview.cloudbrowser.xyz/uploads/file5rc5.9nhts2j...
Here's that Tesla link (I'm making it permanent now):
https://secureview.cloudbrowser.xyz/uploads/filecp9z.ohbtt6u...
Typically with little projects like this it is customary to discuss how you built the application.
The reason they're named that way is an artifact of how this was meant to be a private service to let a remote cloud browser view PDF (etc) files securely, without forcing the client to download them.
So initially I didn't intend to make this public as its own service because the service was supposed to have only 1 customer (this other service).
It wasn't easy at first, as ImageMagick took a long time to convert PDFs at 300 dpi, so I rebuilt it with multicore support, and still it took a long time. I eventually discovered a sweet spot at 100dpi.
But aside from that I tried to keep it very simple, it's just some Node.JS and some shell scripts running on FreeBSD on digital ocean.
Another reason is I made this to convert the PDF (or Word doc, XLS, etc) remotely without the file ever touching the user's device. So they couldn't be exposed to any exploits contained in the file or of the PDF engine (PDFium recently caused a Chrome 0 day I think).
I typically don't like using remote resources for stuff that I can do locally. But for iffy pdfs, it's a good tradeoff.
Edit: Nice to see the PDF capability added :)
This made me think that the site accepts a URL to a PDF/XLS/DOC file and returns PNG.
Actually, that is basically what happens in the original context for this service.
If you take a look at
open a remote browser, then search for a PDF/XLS/DOC etc and then click on it, you'll see a dialog which says the file is transferred.
What's happening is the remote browser downloads the file to a temp directory in the cloud, then some software does a POST request with that file to the service (Simple PDF to PNG Server) and gets the viewing link back immediately, before the conversion has completed.
It then sends the viewing link back to the remote browser which opens a tab. The client can then view the document as images securely without the file ever touching their device.
Originally, I didn't intend to release this viewer as a separate thing/product/service.
If you use the viewer (without the remote browser) you do have to submit the file. I didn't make it to fetch them. I made it as a "secure document viewer" for the remote browser product.
It can start to bog down with large image heavy pdfs. But overall it runs performantly.
[0]: https://www.gnu.org/licenses/agpl-3.0.en.html
[1]: https://tldrlegal.com/license/gnu-affero-general-public-lice...
Not being snarky, but the submission title does say "Server".
For example, this DOC to PDF converter: https://github.com/as-a-service/pdf