@vincent15000 Have you tried this?
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
@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.
@vincent15000 When you say encrypted, you mean that the package needs to be able to give a password to the pdf to unlock it?
@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 But you can open that pdf in a pdf viewer without passwords or similar ?
@Sinnbeck Yes I can open it without any problem without any password.
@vincent15000 Can you post a test file perhaps so we can see it and test ourselves?
@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 Did some googling. https://uwaterloo.ca/onbase/sites/ca.onbase/files/uploads/files/samplecertifiedpdf.pdf is this encrypted ? or this ? https://uwaterloo.ca/onbase/sites/ca.onbase/files/uploads/files/samplesecured_256bitaes_pdf.pdf
@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.
@Sinnbeck I just tested both files.
-
samplecertifiedpdf.pdf : no problem
-
samplesecured_256bitaes_pdf.pdf : problem
@vincent15000 Ok. Good start. So the goal is to remove the encrytion to allow merging?
@Sinnbeck Yes that's right.
@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
@Sinnbeck I just found that, but it's old, not sure it works with recent PDF versions.
https://stackoverflow.com/questions/54313682/how-to-remove-pdf-restrictions-from-php-or-javascript
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
@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.
@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
@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 ;).
@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
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 You are very good at math ;).
@vincent15000 Ah right you are French. You could look at Hetzner. They are really really cheap and German based. I use them myself
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)
@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.
@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 Yeah I have used the cheapest before and had zero issues :)
@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.
@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 ;).
@vincent15000 If you let ploi.io set it up for you, you will get a looong way with no effort :)
@Sinnbeck All this sounds good.
Now I have to choose the best way. ;)
@vincent15000 Did you solve this issue? I have the same issue ?
@jafar112 I have found this API which proposes a free use until 100 PDF files generated per month.
Please or to participate in this conversation.