views:

33

answers:

2

Hello

i am using Imagemagick for converting my .pdf file to .png images

but when i issue the command

$convert sample.pdf image.png

then it will convert all the pages of sample.pdf file to .png images but exactly i want to

convert a specific no. of pages(e.g. first 10 pages or page no.22 or 12 etc.)

then pleases suggest me a way to solve this issue.

and one more question is that:

when we view our .pdf files in google docs .pdf viewer then they are also in image format

but we can select and copy the text written on pages to the clipboard(simply select the text and press

Ctrl+c)

so how can i implement this so the users of my website can select the text form my images.

(there are already some discussion about it on stackoverflow but they are not very clear)

+3  A: 

Hello!

for i in {1..10} 12 22
do
    convert "sample.pdf[$i]" "image_$i".png
done
Benoit
+1 This is the simplest solution.
Octavian Damiean
@Benoit:thank you very much
Peeyush
@Peeyush: You are welcome :)
Benoit
+1  A: 

Benoits answer is what you were looking for for slicing and converting a PDF in to images.

Alternatively you can use pdftk with the cat operation. This would get you the first 10 pages and generate a new sliced PDF for example.

pdftk YOUR.PDF cat 1-10 output SLICED.PDF

Regarding your second question about converting an image PDF to a PDF with text data the only way is to use a OCR tool like Tesseract for example.

The only problem is that those OCR tools are not always that exact. In other words sometimes they will not always be able to output what you read on that image.

Octavian Damiean
thanks Octavian
Peeyush