Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

API to flatten and merge PDF files

Hello,

I have a client who doesn't want to pay for an API because he needs to generate a very little amount of PDF each month (less than 100).

So I'm looking for a free API to flatten and merge PDF files. For the moment I have installed the DomPDF package which works fine unless the PDF files have layers or are encrypted.

I searched on the web for the different possibilities, but I don't have found only one API which has a free plan.

What can you suggest me ? Do you know any PDF API with a free plan for little usage ?

Thanks for your help.

Vincent

0 likes
32 replies
vincent15000's avatar

@tisuchi Thank you, I don't remember, I think I already tried it in the past when I developed the application. But I will try it once again to be sure.

What I already tried is :

  • barryvdh/laravel-dompdf

  • clegginabox/pdf-merger

  • daltcore/lara-pdf-merger

And no one works with encrypted PDF files or PDF files with layers.

Sinnbeck's avatar

@vincent15000 When you say encrypted, you mean that the package needs to be able to give a password to the pdf to unlock it?

1 like
vincent15000's avatar

@Sinnbeck I don't really know ... with DomPDF I get an error related to secured file / encryption and I discussed with SetaSign who told me that there is probably a password and that they have a snippet to unlock the PDF files in their package.

vincent15000's avatar

@Sinnbeck Hmmm ... I first need to ask for an authorization from my client, I can't share you any of his files without his authorization. And I don't have a test file with the same problem.

vincent15000's avatar

@Sinnbeck Ok thank you I didn't know these samples, that's very interesting. I will test with both files and I give you the answer right now.

vincent15000's avatar

@Sinnbeck I just tested both files.

  • samplecertifiedpdf.pdf : no problem

  • samplesecured_256bitaes_pdf.pdf : problem

Sinnbeck's avatar

@vincent15000 Ok. Just trying to find a way to detect if its actually encrypted. If you know of a commandline tool to check that let me know

1 like
Sinnbeck's avatar

Ah ok I got it.

Install xpdf-utils

sudo apt-get install xpdf-utils

check if it has encryption pdfinfo file.pdf. It says Yes

Now convert to ghost script

pdftops file.pdf

and convert it back

ps2pdf file.pdf.ps fixed.pdf

Check it again. pdfinfo fixed.pdf. It is now no longer encrypted

1 like
vincent15000's avatar

@Sinnbeck The problem is that the application is on a shared webhosting and it won't be possible to install any OS package on the server. That's why I have to find another solution.

Sinnbeck's avatar

@vincent15000 Ok. Then I get why you are out for a free api. My guess is that if you cannot find it on google, it does not exist. Perhaps make one yourself and give it to the client for free? :) Or convince them to use a real server, Digital ocean is cheap

1 like
vincent15000's avatar

@Sinnbeck The client doesn't want to pay for an API. So I'm trying to find a free API.

But it probably doesn't exist ;).

He paid around 8 EUR per month to use SmallPDF and he didn't want to pay this anymore.

Sure I won't make one myself and give him for free ;).

1 like
Sinnbeck's avatar

@vincent15000 Hm ok. My math tells me that your salary for doing this would cost the same as like 10 years of using that service ? :D

1 like
vincent15000's avatar

I never worked with DigitalOcean.

For the moment he has a shared webhosting with SSH access for around 12 EUR per month.

It's a very small app with very small payloads and only one use is using it.

Which plan would you suggest by DigitalOcean ?

Sinnbeck's avatar

@vincent15000 Ah right you are French. You could look at Hetzner. They are really really cheap and German based. I use them myself

https://www.hetzner.com/cloud

Check the prices. Even the smallest server is great, and dirt cheap. You just need to set it up manually (or use the free tier at ploi.io to set it up)

1 like
Tray2's avatar

@vincent15000 If it is more of intranet application rather than an internet one, then self hosting is always an option, then you can install anything.

1 like
vincent15000's avatar

@Sinnbeck That looks interesting. I think that even the first plan could do the work for this small app.

For the moment the application is hosted by Ionos.

vincent15000's avatar

@Tray2 I don't think that self hosting it would be a good idea for my client.

I already thought about hosting his application on my VPS, but I initially didn't want to do that.

Perhaps it's a good idea to think about it.

vincent15000's avatar

@Sinnbeck Could servers seem to be interesting but I'll have to learn how to secure it ;). I'm not so good at this job ;).

Please or to participate in this conversation.