0

I have a PDF file with images, text and prices. I want to add a discount to the prices. Is it possible with PHP to find the prices and edit them? It would be easy to find the pattern with a regular expression, possibly /Price: [0-9,]*,-/. I also know there is possible to extract the text from the PDF and re-write the file, but how can I edit it on the fly?

Bojangles
  • 99,427
  • 50
  • 170
  • 208
PDFedit
  • 59
  • 4
  • You would probably be better off reconstructing the PDF and use something [TCPDF](http://www.tcpdf.org/) to output a dynamic PDF. – Jared Farrish Sep 05 '11 at 20:38

3 Answers3

0

I have done this before! You can either use an HTMLtoPDF or SVGtoPDF framework. Then you enter the variable that you want to be changed in your PDF using PHP. For example,

<svg>
<text>'.$variable.'</text>
</svg>

You then pass the new edited script through the library and tada!

0

I think you need a product like Prince to create PDF files from PHP.

Rijk
  • 11,032
  • 3
  • 30
  • 45
  • 1
    [TDPDF](http://www.tcpdf.org/) is free and pretty well spec'd, although I understand Prince is pretty good. – Jared Farrish Sep 05 '11 at 20:34
  • I dont wanna create PDF's i want to EDIT them. I know there is a t least 4 good libraries to create PDF but i couldnt find one example on editing. – PDFedit Sep 05 '11 at 21:23
0

Even with Adobe Pro, you can't very well edit a pdf file unless it's made to be edited...

That said - We can continue to provide ways to edit if you provide a link to the pdf so we can see it ourselves though.

Shackrock
  • 4,601
  • 10
  • 48
  • 74