pdf to image within Live Code?

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

pdf to image within Live Code?

Post by admin12 » Thu Jun 30, 2011 4:25 pm

In the program I am writing, I need to allow users to upload files. Some will upload as jpg and some as pdf. What I want to do is convert the pdf files to jpg or png and store them on the file server as that. Will the snapshot command work for this? If not, is it possible within Live Code?

Mike

Klaus
Posts: 13858
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: pdf to image within Live Code?

Post by Klaus » Thu Jun 30, 2011 4:30 pm

Hi Mike,

on the Mac you could use a shell command with "SIPS" (enter "man sips" in the terminal),
no idea about windows.


Best

Klaus

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: pdf to image within Live Code?

Post by admin12 » Thu Jun 30, 2011 6:29 pm

Klaus,

99.99% of anyone using this will be on windows.

Mike

Klaus
Posts: 13858
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: pdf to image within Live Code?

Post by Klaus » Thu Jun 30, 2011 7:09 pm

OK, so my advice is only for the remaining 0.01 % users.
Could be worse 8)

SparkOut
Posts: 2857
Joined: Sun Sep 23, 2007 4:58 pm

Re: pdf to image within Live Code?

Post by SparkOut » Fri Jul 01, 2011 12:28 am

Cross-platform, I think you should be able to view the pdf in a browser window and then use "revBrowserSnapshot" to export the snapshot of the pdf display to a variable that can be saved into an image file.

admin12
Posts: 412
Joined: Wed May 11, 2011 9:47 am

Re: pdf to image within Live Code?

Post by admin12 » Sat Jul 02, 2011 6:40 pm

SparkOut wrote:Cross-platform, I think you should be able to view the pdf in a browser window and then use "revBrowserSnapshot" to export the snapshot of the pdf display to a variable that can be saved into an image file.
Perfect. That is what I was hoping. Thank you.

Mike

Lakoza
Posts: 1
Joined: Wed Oct 15, 2014 7:23 pm

Re: pdf to image within Live Code?

Post by Lakoza » Wed Oct 15, 2014 7:25 pm

Another cross-platform solution https://convertio.co/pdf-jpg/

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: pdf to image within Live Code?

Post by [-hh] » Thu Oct 16, 2014 1:44 am

Snapshot is currently at some low "density" (some say 'at dpi'), mostly at 72 dpi. "Big" imaging apps ask you at which "resolution" the pdf should be imported.

To have this also with an open source tool, you could install on Mac-Win-Linux graphicsMagick (needs on Windows also ghostScript). This is very fast and enables you to have the image in a certain resolution, in case you think of scaling the image for some high-resolution displays or think of printing it. Installing is easy (good documented).

You can use this by "shell". For example:

Code: Select all

-- Converts your PDF to an image at advanced LaserPrinter quality (600 dpi)
-- JPG is small in size, PNG preserves transparency, GIF holds multipages of PDF
-- All formats are good for PDF-Text if density is good enough (try first 144)
set defaultfolder to "/your-home/folder-containing-input-pdf"
get shell("gm convert -density 600 input.pdf output.png")
shiftLock happens

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: pdf to image within Live Code?

Post by Thierry » Thu Oct 16, 2014 4:15 am

Hi,

Are you aware of this Windows only product (not free)?

http://www.soraxsoft.com/pdf/sdk/dll.php#sdk_dll

and there is a Livecode external for it: sunnYpdf

You can contact me off-list if you are interested.

Regards,

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: pdf to image within Live Code?

Post by [-hh] » Thu Oct 16, 2014 4:47 am

Concluding from the very high quality of sunnYmidi, I presume sunnYpdf will be also perfect. This could be interesting for everybody who has to do a lot of such conversions.
Moreover, the new CEF browser of LC has and will have for next time a *lot* of problems to display local pdfs (that is, to make the adobe reader plugins working).

Perhaps you could think about offering sunnYpdf (or give more info about it) on your homepage?
shiftLock happens

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: pdf to image within Live Code?

Post by Thierry » Thu Oct 16, 2014 5:00 am

[-hh] wrote:Concluding from the very high quality of sunnYmidi,
I presume sunnYpdf will be also perfect.
Hallo Hermann,
Wow. Sounds Christmas time coming sooner this year :)
Perhaps you could think about offering sunnYpdf (or give more info about it) on your homepage?
Here it is: ..........

Kind regards,

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

Post Reply

Return to “Multimedia”