3
I’m with a project that I need to add header/footer/watermark, dynamically in existing PDF files, via PHP language.
I’ve done a lot of research and I still can’t find a way to do this.
You can edit existing PHP Pdfs and add information?
Or, it would be possible to create a new PDF, through an existing one, and so be able to edit the contents of this new PDF?
Another way I thought would be to transform the existing PDF into HTML and then turn this HTML into a new PDF with the header/footer/watermark.
That’s a lot of questions in one question, but that’s okay. Well, I want to tell you that 60% of you crave cannot. There are several PHP classes that handle Pdfs. You can create PDF, but editing PDF might be a long way. It depends a lot on what editing pdf means. Creating a footer for example could be relatively easy, but changing a text in the pdf will depend on many factors, starting with the way this PDF was created. Look at this example
– durtto
I don’t know if it’s possible either, but try to see mPDF https://github.com/mpdf/mpdf
– Ivan Nack
If they are not too complex, perhaps the quickest is to simulate/recreate these existing HTML pdfs...
– brasofilo
Yes @brasofilo, there are several possibilities, only it needs to be clearer what it means edit a pdf.
– durtto
@durtto, I imagine there is not much mystery, means do what Acrobat Pro or Nitro PDF do: open a PDF and paste/remove elements and record a new one. I don’t think it’s "too many questions in one", for me it’s clear: how to open an existing PDF, paste a header and footer, record a new PDF.
– brasofilo
http://stackoverflow.com/questions/12510117/using-fpdf-to-modify-existing-pdf-in-php
– Daniel Omine
Guys, I managed to solve my problem with what was posted by @durtto using the FPDF and FPDI libraries. Thank you all! Example: https://rubayeet.wordpress.com/2010/02/modifying-pdf-files-with-php/
– Willian
The @Daniel Omine link also helped me! Thank you!
– Willian
This is really good. Willian, so now I’m going to turn my comment into an answer and if you think it was an answer to your question, mark it as accepted. It was a pleasure to help.
– durtto