Hi, I’m looking for a script (PHP preferably) that I can use to allow my users to upload their PDF to my website, view the uploaded PDF in a browser viewer, and have the ability to add images, position the image (by pointing or dragging the image), then save and download the amended PDF.
While there are many images and HTML editing script, I can’t seem to find one for PDF.
Has anyone used such a script? Thank you.
p/s:
I do not need the ability to amend existing text or graphics on the uploaded PDF.
HTML to PDF converters also don’t work as I need to modify existing PDF.
Unfortunately, you’re not going to have much luck with this. PDF and HTML are two completely different animals: HTML is a user-friendly language designed for flexible-boundary (i.e. browser) interfaces, whilst a PDF file is ugly due to compression, strict page boundaries, specific typesetting rules and various other factors.
There are PHP libraries available for “opening” a PDF, inserting a page and adding things to that page, but inline editing really isn’t an option - it’s feasible (though no PHP library I know of has the functionality) to change a font or correct a typo, but reflowing text and inserting an image is insanely difficult.
In fact, I’d say your best bet is to find a terminal-based application which attempts to convert a PDF file into LaTeX, and come up with a way of modifying that LaTeX to insert and place the image. This would be more viable because LaTeX is specifically (and rather beautifully) designed to typeset PDF files (and similar other formats) such that formatting remains consistent and logical. However, the best of the available converters are awful, because it’s such a hard job.
To put this in a comparative context, this is similar (in a way) to the task of trying to decompose a JPEG file of a family photo and putting George Clooney in with his arm around Grandma, who was originally standing inbetween two other family members - whilst retaining the original wallpaper. It’s pretty much impossible to do it well manually with MS Paint, let alone writing a program to do it for you.
Hi Jake, thank you for your suggestions. I’ve not heard of LATEX previously and will be doing some research on it.
PDFEscape.com had been doing this for about 5-6 years (it even supports IE 6), allowing PDF docs to be uploaded and drawings, images and text to be added via a WYSIWYG editor. Yesterday, I found another website, touchpdf.com that does something similar although the interface is not as good.
Hi Stephen, thanks, your references are helpful. I tried out fpdi with fpdf, I’m able to get it to insert an image using code, e.g. $fpdf->Image(‘fpdf/image.jpg’, 100, 60, 100, 80);
But I’ll still need to find a way to provide a “wysiwyg” interface that a user can use to position the image onto a rendering of the PDF on the webpage. Any thoughts?
Yes, found out about that while checking out pdf.js which uses HTML5, but is only limited to reading the PDF.
However,HTML5 is only supported by the latest browsers and my user’s office PCs are still using older version of IE.
After much research, I’m starting to think that I’ll need to separate out the IU from the actual code that generates the PDF (which can be handled by FPDI + FPDF).
PDFescape supports IE6 as shown in the screen capture below so there must be an easier way:
That’s very bad on your company / department as it poses a high security risk to your company network. They are exposing your systems to every exploit going, update of web browsing services is of paramount importance as it is one of the ways in which a system can be compromised no matter how good your network or security is.
So, you need to emphasize the risks to your network administrators who should really know better than to run outdated services or systems. MSIE6 is a whole bag of trouble, it has security holes that big you could fly and A380 Airbus through.