Approach to PDF input within LC

Jan Schenkel janschenkel at yahoo.com
Mon May 9 14:24:19 EDT 2011


--- On Mon, 5/9/11, Graham Samuel <livfoss at mac.com> wrote:
> I am trying to write an app in LC
> that reads PDFs (actually just images, so a restricted
> version) as well as various other formats which LC can
> tackle directly like JPG (this easy bit is already coded).
> This has to work on Windows and it has to be free, since my
> users are very price-sensitive. 
> 
> As there is no native method for opening PDFs in LC, I will
> have to run another process to do this. I want my user to be
> unaware of the complications involved, and to have a very
> simple one-step installation procedure. 
> 
> I am sadly ignorant of almost everything I need for this
> (command-line controls, the 'shell' concept, interprocess
> communication, 'free' software etc etc, even the behaviour
> of Windows itself), but so far I have seen two possible
> solutions: to use ImageMagick, which is a freestanding app
> that can be installed on Windows and run via shell (I
> think); and using ICEpdf, which is a Java program
> specialising in PDF reading, which (obviously) means that my
> user has to install Java as well as the program itself.
> 
> For me this is a very steep learning curve indeed, and I
> would be grateful for any pointers toward the best way to
> tackle this problem and how to learn enough to do it. Later
> I will have to go through the whole wretched issue again
> with TIF files. I almost feel like writing my own input
> method, since at least I am confident in LC - but I suppose
> that way madness lies.
> 
> TIA
> 
> Graham
> 

Hi Graham,

ImageMagick can convert PDF files to images, but only if GhostScript is installed; and in the Java world, both ICEpdf and PdfRenderer can render PDF files to images. All these options introduce dependencies on some sort of additional installs, I'm afraid.

I've never tested this, but you could try loading the PDF file in a revBrowser instance, and use the revBrowserSnapshot command to extract a snapshot - though that may only work for HTML pages, and I have no idea how you'd flip through the individual pages of the PDF file.

Looking at the code of Quartam PDF Library, I can think of a way to extract JPG images, but that would not suffice for other types of images in the PDF file. Could be a cool project if someone wants to tackle adding it to the open source project ;-)

Jan Schenkel.
=====
Quartam Reports & PDF Library for LiveCode
www.quartam.com

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)





More information about the use-livecode mailing list