lorempdf.com - Create sample PDFs quick and easy

The best projects are probably those, where you have some kind of interest in it working. My newest project is something like that, too. Although the „I always wanted to build something like this“-part predominates.

From time to time I need test files at work to check workflows or only specific process steps. For various reasons you do not want to use real customer data, so you often start up InDesign, create a document with whatever text or image in it and write a PDF from this. Obviously this always takes some time.

To make this process easier, I have finalized lorempdf.com at the weekend. It has been in a „90% done“ status for quite some time, but I still had to approve my app for production mode with Unsplash. As I have finally finished this, this little project is good to go.

What does it do?

In the sense of the world-famous „Lorem Ipsum“ dummy text, this little service creates PDF files without any real content. Dummy PDFs if you'd like to call them that way. To accomplish this, a PDF file is created with the desired size and pagecount and it gets filled with random images from Unsplash after that. The result can be used as you wish or need in your workflow.

How does it work?

First this little service checks, whether all three parameters are set in the URL and are within a valid range. The first value is the width in mm, the second the height in mm, the third one is the pagecount of the created PDF.

Valid values are 1 to 1000 for width and height and 1 to 100 for the pagecount. This was choosen somewhat random, if anybody needs bigger files, just write me a mail and I will raise those limits.

If these values are valid, PDFlib is used to create a new, empty PDF file. A random image is fetched via the Unsplash API which fits the aspect ratio of the PDF. This file is temporarily savaed, scaled to its final size and placed in the PDF. Last but not least, an overlay with photographer information is created and the finalized file is returned to the browser.

Any errors will throw messages which can be handled in an appropriate way.

Why PDFlib?

While we have even more powerful PDF generators/manipulation software (pdfToolbox/pdfChip by Callas for example) in the print and media industry, PDFlib has the big advantage that it runs even on smaller webservers and can be controlled via PHP.

Hosteurope for example has the PHP module for PDFlib integrated even in their smaller webhosting packages, so that you can easily start with creating PDF files. But installing or integration a PHP module should not be a big deal for a server administrator after all. To be honest, I have struggled with this in the beginning, but everybody starts small...

PDFlib is by the way also the technology in the background for Web2Print systems like printQ by Cloudlab, or the software I used at Longo when writing an application to create tin labels for mymuesli. (The post (German!) seems to be only available through the wayback machine, the blog does not work anymore.)

In short: PDflib ist not an Unknown, when you are working with the automated generation of PDF files. And as I know my way around it, it was rather obvious to use it for this little project.

What can be improved?

Fetching a random image from Unsplash brings some latency with itself. For being able to create high resolution data in the PDF files, the script fetches the biggest possible version of the image. That is obviously good for the quality but bad for the loading time.

One could think about caching the images, but it's also charming to receive a new image with each call of the generator. So, caching could be counterproductive.

Besides that, you can think about lots of tinkering with the PDF file. Different page sizes per page, changing content per page, specifically created errors, various PDF standards, the list goes on and on.

But as the project right now fulfills my requirements, I would some specific feedback from the outside in regards of feature requests.

As always: Have fun with it and I'd love to hear any feedback.


Über mich

Ich bin gelernter Mediengestalter, studierter Druck- und Medientechniker und leidenschaftlicher Tüftler und Bastler.

Beruflich beschäftige ich mich mit der digitalen Transformation von Unternehmen, sowie der Automatisierung von Unternehmensprozessen, in der Druck- und Medienbranche. Mehr dazu findet sich im Lebenslauf.

Privat interessieren mich Kaffee(maschinen), Themen rund um Webentwicklung, das Internet im Allgemeinen und Speziellen und vieles, vieles mehr.

Ich freue mich auf Feedback per E-Mail unter kontakt@flomei.de, einen Euro für die Kaffeekasse oder etwas von meiner Amazon Wunschliste.