Help with "advanced" shell scripting | how to create an image preview of a pdf

Posted by lucapozzobon on Ask Ubuntu See other posts from Ask Ubuntu or by lucapozzobon
Published on 2013-06-29T21:29:23Z Indexed on 2013/06/29 22:28 UTC
Read the original article Hit count: 321

Filed under:
|
|
|
|

First of all, sorry for my english: i'm not british/american.

Here is my problem. I've got a folder named pdf with lots of files pdf inside it. I've got another folder named thumbnail, which is empty. I want to create jpg images preview of each pdf to use them in my HTML webpages as previews of the pdf.

To do this I'm using a software called IMAGEMAGICK. I tried to put the code inside my PHP files to get the purpose, but it doesn't work. As you understood, I have created a small search engine with apache, mysql to search for pdf locally (offline). Now I want to add a "preview" of the first page of pdfs. Instead, it works by bash command line and the code is:

convert pdf/name_of_the_file_pdf.pdf[0] name_of_the_imagefile.jpg

(The zero stands for that the image is taken from the FIRST page of pdf) How can i make a script that takes each name of pdf files and put it into that code???? To list all the file, I did

ls >pdf

but with the little knowledge I have I can't go further.... Some pdf's names contain spaces....Is that a problem?

PDF files are so many that i can't do the task typing every name,it wouldn't be a nice and clever work!!!! Thanks a lot in advance!!!

© Ask Ubuntu or respective owner

Related posts about 12.10

Related posts about command-line