3

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)

1
  • 2
    That second question should be a separate one.
    – Pekka
    Sep 30, 2010 at 11:29

2 Answers 2

7
for i in {0..9} 11 21
do
    convert "sample.pdf[$i]" "image_$i".png
done
0
3

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.