I’ve read PDF Editing in PHP? but haven’t found quite what I’m looking for.
Basically I need to take a DOC (read: not .docx) file, which will be used as a template, find certain strings (e.g, [Patient Number], [Site Number], etc) replace them with values that I’ll retrieve from a database and then save that file as a .pdf file.
Here’s the important points
- I’d rather avoid zend framework (or any framework) for the purpose of keeping my application’s software light and not having to maintain another 3rd party piece of code in this project (jquery,jquery-UI,jqGrid, etc)
- I can’t use DOCX because I don’t have that version of Office installed on my work computer. I will eventually, but I don’t know when that’ll happen and I need to finish coding this ASAP
- The converting to PDF at the end is somewhat optional. I’d like to have it as interoperable as possible. I already have ezPdf and fPdf on the system, so perhaps I can just feed the generated Word binary into ezPdf/fPdf and generate the PDF that way.
Are there any PHP libraries out there that allow reading a .doc file and then the ability to edit the text and then write it back to the disk?
I’ve tried ezPdf and fPdf, but the specifying of text block coordinates got too tedious and involved too much guesswork and trial & error.
Thanks in advanced!
I ended up using docx (with the assistance of my co-worker (who had office 2007) exporting the file for me) and completely (for now at least) forsaking the PDF conversion.
I did install phpdocx and after juggling around with a bunch of extensions (XSL, mbstring, etc) I had to get the server administrator to install, it did generate the PDF based off of my generated docx file, it didn’t convert the styles or image used in the header, so it looked absolutely horrible.
Due to time constraints, I had to completely skip out on PDF conversion and just use the docx file. This will be something we re-visit in the future, but for now, docx it is.
We might also look into LiveDocX, but unfortunately that deals with uploading files to the cloud and because these files contain patient date (however, mostly blinded) I have to get approval from our legal department to make sure we’re in accordance with HIPAA privacy laws.