janschenkel at yahoo.com
Mon Dec 6 01:24:44 EST 2010
--- On Sun, 12/5/10, Anthony Howe <anthonyhowe at me.com> wrote:
> My question was also not really
> around whether PDF export is possible, but rather if it was
> possible to open an existing PDF file (which was created in
> LC, or not) and add new data (like a personalized footer or
> header from LC app data for example), then, reexport it...as
> a PDF, ready for distribution.
> The answer to this one so far seems to be no.....but I'm
> hoping for an angle....:)
> Hope that clarifies things, and perhaps I should have
> started a separate thread on this question, as I accept it
> does stray somewhat from the original post.
While I have written a library to create new PDF files from scratch, by script, I'm not sure where to begin taking apart an existing PDF file and modifying its content.
The structure of a PDF file is completely unlike Word DOC or RTF files. Word processing files are structured around a flow of paragraphs, sentences and words. PDF files are a set of low-level instructions (draw a line here, draw this bit of text there, now switch to font 'Times', set the drawing color to 'red', etc.) and there is no rigid flow structure.
More precisely, PDF has no concept of paragraphs - you're at the mercy of the producing application printing each bit of text in the 'right' order to ease extraction. In fact, PDF doesn't even have text styling concepts other than 'font'. You want an underline? Draw it yourself.
In fact, it's so complicated that the selection of text in Adobe Reader or Apple Preview is based on OCR (optical character recognition) algorithms: we know there's a bit of text here, and that other bit of text has the same baseline, so that could actually be a single line of text in the user's mind - let's select both!
So if you're looking to read an existing file, and modify the content - such as replacing placeholder text and expecting the whole flow of the text to update along with it - you have your work cut out for you.
One feature I have been working on, is the ability to open an existing PDF file, and use pages from it as a background on top of which you draw additional elements. In that scenario I'm not even really tweaking the content, and this is presenting its own gotchas...
Quartam Reports & PDF Library for LiveCode
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
More information about the use-livecode