473,322 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Extract Image From PDF

Hi all

Does anybody please know a way to extract an Image from a pdf file and save
it as a TIFF?

I have used a scanner to scan documents which are then placed on a server,
but I need to extract the image of the document (just the first page if
there are multiple pages) and save it as a TIFF so I can then use the
Tesseract OCR to get the text in the image.

I think there may be a license of Adobe Acrobat Professional in the company
I am working for if they provide a way to do this in my .NET application.

Thank you for your help.

Kind Regards,
Steve
Aug 22 '08 #1
5 5702
I don't know of a Net way exactly, however you can check out Ghostscript
which will allow you to read a Pdf and save it as a Tiff. I think you can
specify page numbers to convert. You can call Ghostscript from a command
line with your params with Process.Start.

hth,

Rick
"Steve" <st***************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hi all

Does anybody please know a way to extract an Image from a pdf file and
save it as a TIFF?

I have used a scanner to scan documents which are then placed on a server,
but I need to extract the image of the document (just the first page if
there are multiple pages) and save it as a TIFF so I can then use the
Tesseract OCR to get the text in the image.

I think there may be a license of Adobe Acrobat Professional in the
company I am working for if they provide a way to do this in my .NET
application.

Thank you for your help.

Kind Regards,
Steve
Aug 22 '08 #2
Hi Rick

Thanks for that. I have downloaded and installed Ghostscript. I have a demo
app that can execute Ghostscript with command line parameters, and at the
moment I can only get the revision number and a thumbnail view of the first
page (JPEG) based on the content I have found.

Do you know the parameters I would need to extract the image on the first
page to a TIFF please? I can't seem to find these amywhere :o(

Here are the args I found to generate a jpeg based on a pdf document:

Dim astrArgs(7) As String
astrArgs(0) = "pdf2jpg" 'The First Parameter is Ignored
astrArgs(1) = "-dNOPAUSE"
astrArgs(2) = "-dBATCH"
astrArgs(3) = "-dSAFER"
astrArgs(4) = "-sDEVICE=jpeg"
astrArgs(5) = "-sOutputFile=C:\Thumbnail.jpg"
astrArgs(6) = "C:\MyPDFDoc.pdf"

Thanks for your help!

Regards,
Steve

"Rick" <Ri**@lakevalleyseed.comwrote in message
news:CB**********************************@microsof t.com...
>I don't know of a Net way exactly, however you can check out Ghostscript
which will allow you to read a Pdf and save it as a Tiff. I think you can
specify page numbers to convert. You can call Ghostscript from a command
line with your params with Process.Start.

hth,

Rick
"Steve" <st***************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Hi all

Does anybody please know a way to extract an Image from a pdf file and
save it as a TIFF?

I have used a scanner to scan documents which are then placed on a
server, but I need to extract the image of the document (just the first
page if there are multiple pages) and save it as a TIFF so I can then use
the Tesseract OCR to get the text in the image.

I think there may be a license of Adobe Acrobat Professional in the
company I am working for if they provide a way to do this in my .NET
application.

Thank you for your help.

Kind Regards,
Steve

Aug 23 '08 #3
I run mine from Net process.start like this:

process.StartInfo.Arguments =
String.Format("-dSAFER -dBATCH -dNOPAUSE -sDEVICE=tiffg3 -sOutputFile=""{0}""
""{1}""", Path.ChangeExtension(fileName, ".tif"), fileName)
if you want to read only the first page you would add -dFirstPage=1
and -dLastPage=1 (see http://web.mit.edu/ghostscript/www/Use.htm )

I am slightly confused about what you really want. I understood you want to
convert the entire first page to a tiff file and then use an OCR program to
read text. If you want to only extract an image from the first page, I'm
not sure this would work. I don't know of a facility to extract an image
from a pdf. You might check iTextSharp which can create and read pdf's. If
you know the name of the image you may be able to extract it.

Also, if you want a Tiff file why are you extracting to a jpeg below?

Rick
"Steve Amey" <steveamey@[removeme]hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi Rick

Thanks for that. I have downloaded and installed Ghostscript. I have a
demo app that can execute Ghostscript with command line parameters, and at
the moment I can only get the revision number and a thumbnail view of the
first page (JPEG) based on the content I have found.

Do you know the parameters I would need to extract the image on the first
page to a TIFF please? I can't seem to find these amywhere :o(

Here are the args I found to generate a jpeg based on a pdf document:

Dim astrArgs(7) As String
astrArgs(0) = "pdf2jpg" 'The First Parameter is Ignored
astrArgs(1) = "-dNOPAUSE"
astrArgs(2) = "-dBATCH"
astrArgs(3) = "-dSAFER"
astrArgs(4) = "-sDEVICE=jpeg"
astrArgs(5) = "-sOutputFile=C:\Thumbnail.jpg"
astrArgs(6) = "C:\MyPDFDoc.pdf"

Thanks for your help!

Regards,
Steve

"Rick" <Ri**@lakevalleyseed.comwrote in message
news:CB**********************************@microsof t.com...
>>I don't know of a Net way exactly, however you can check out Ghostscript
which will allow you to read a Pdf and save it as a Tiff. I think you can
specify page numbers to convert. You can call Ghostscript from a command
line with your params with Process.Start.

hth,

Rick
"Steve" <st***************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Hi all

Does anybody please know a way to extract an Image from a pdf file and
save it as a TIFF?

I have used a scanner to scan documents which are then placed on a
server, but I need to extract the image of the document (just the first
page if there are multiple pages) and save it as a TIFF so I can then
use the Tesseract OCR to get the text in the image.

I think there may be a license of Adobe Acrobat Professional in the
company I am working for if they provide a way to do this in my .NET
application.

Thank you for your help.

Kind Regards,
Steve

Aug 23 '08 #4
Thank you, I'm generating tiff files now.

The pdf is an image of a scanned document. I would like to get the text of
the scanned image. I looked into OCR, and came across Tesseract. To my
knowledge, Tesseract can (only) read a tiff file and extract the text. If I
open up a document in Adobe Pro and save the scanned image as a tiff,
tesseract does read most of it quite well, but my problem is that I have to
automate the process and can't open up the documents and manually save the
images, so I need something to extract the scanned image in the pdf file and
save it as a tiff so tesseract can read it. I tried iTextSharp already but I
get an error "PDF header signature not found", which I'm guessing is a
problem with the way the scanner creates the pdf files and iTextSharp can't
open it.

I found some sample code that creates a jpeg, which is what I posted, but I
didn't know how to create a tiff file, but I see that it's just a case of
changing the -sDEVICE parameter to the one you are using.

Unfortunately, the resulting tiff image is not great quality and tesseract
makes many errors when trying to read it, so I have to find another way or
give up :o(

Thank you for your help, if you know of any other way to do what I'm trying
then I'd love to know! I don't mind paying a small amount for some
commercial software that can extract images from pdf docs that I can use in
..NET, but I haven't found any yet that don't cost hundreds or even thousands
of dollars.

"Rick" <Ri**@lakevalleyseed.comwrote in message
news:F4**********************************@microsof t.com...
>I run mine from Net process.start like this:

process.StartInfo.Arguments =
String.Format("-dSAFER -dBATCH -dNOPAUSE -sDEVICE=tiffg3 -sOutputFile=""{0}""
""{1}""", Path.ChangeExtension(fileName, ".tif"), fileName)
if you want to read only the first page you would add -dFirstPage=1
and -dLastPage=1 (see http://web.mit.edu/ghostscript/www/Use.htm )

I am slightly confused about what you really want. I understood you want
to convert the entire first page to a tiff file and then use an OCR
program to read text. If you want to only extract an image from the first
page, I'm not sure this would work. I don't know of a facility to extract
an image from a pdf. You might check iTextSharp which can create and read
pdf's. If you know the name of the image you may be able to extract it.

Also, if you want a Tiff file why are you extracting to a jpeg below?

Rick
"Steve Amey" <steveamey@[removeme]hotmail.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>Hi Rick

Thanks for that. I have downloaded and installed Ghostscript. I have a
demo app that can execute Ghostscript with command line parameters, and
at the moment I can only get the revision number and a thumbnail view of
the first page (JPEG) based on the content I have found.

Do you know the parameters I would need to extract the image on the first
page to a TIFF please? I can't seem to find these amywhere :o(

Here are the args I found to generate a jpeg based on a pdf document:

Dim astrArgs(7) As String
astrArgs(0) = "pdf2jpg" 'The First Parameter is Ignored
astrArgs(1) = "-dNOPAUSE"
astrArgs(2) = "-dBATCH"
astrArgs(3) = "-dSAFER"
astrArgs(4) = "-sDEVICE=jpeg"
astrArgs(5) = "-sOutputFile=C:\Thumbnail.jpg"
astrArgs(6) = "C:\MyPDFDoc.pdf"

Thanks for your help!

Regards,
Steve

"Rick" <Ri**@lakevalleyseed.comwrote in message
news:CB**********************************@microso ft.com...
>>>I don't know of a Net way exactly, however you can check out Ghostscript
which will allow you to read a Pdf and save it as a Tiff. I think you can
specify page numbers to convert. You can call Ghostscript from a command
line with your params with Process.Start.

hth,

Rick
"Steve" <st***************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
Hi all

Does anybody please know a way to extract an Image from a pdf file and
save it as a TIFF?

I have used a scanner to scan documents which are then placed on a
server, but I need to extract the image of the document (just the first
page if there are multiple pages) and save it as a TIFF so I can then
use the Tesseract OCR to get the text in the image.

I think there may be a license of Adobe Acrobat Professional in the
company I am working for if they provide a way to do this in my .NET
application.

Thank you for your help.

Kind Regards,
Steve



Aug 23 '08 #5
http://www.foolabs.com/xpdf/

pdfimages - Portable Document Format (PDF) image extractor
(version 3.02)


"Steve Amey" <steveamey@[removeme]hotmail.comwrote in message
news:#F**************@TK2MSFTNGP05.phx.gbl...
Hi Rick

Thanks for that. I have downloaded and installed Ghostscript. I have a
demo app that can execute Ghostscript with command line parameters, and at
the moment I can only get the revision number and a thumbnail view of the
first page (JPEG) based on the content I have found.

Do you know the parameters I would need to extract the image on the first
page to a TIFF please? I can't seem to find these amywhere :o(

Here are the args I found to generate a jpeg based on a pdf document:

Dim astrArgs(7) As String
astrArgs(0) = "pdf2jpg" 'The First Parameter is Ignored
astrArgs(1) = "-dNOPAUSE"
astrArgs(2) = "-dBATCH"
astrArgs(3) = "-dSAFER"
astrArgs(4) = "-sDEVICE=jpeg"
astrArgs(5) = "-sOutputFile=C:\Thumbnail.jpg"
astrArgs(6) = "C:\MyPDFDoc.pdf"

Thanks for your help!

Regards,
Steve

"Rick" <Ri**@lakevalleyseed.comwrote in message
news:CB**********************************@microsof t.com...
>>I don't know of a Net way exactly, however you can check out Ghostscript
which will allow you to read a Pdf and save it as a Tiff. I think you can
specify page numbers to convert. You can call Ghostscript from a command
line with your params with Process.Start.

hth,

Rick
"Steve" <st***************@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Hi all

Does anybody please know a way to extract an Image from a pdf file and
save it as a TIFF?

I have used a scanner to scan documents which are then placed on a
server, but I need to extract the image of the document (just the first
page if there are multiple pages) and save it as a TIFF so I can then
use the Tesseract OCR to get the text in the image.

I think there may be a license of Adobe Acrobat Professional in the
company I am working for if they provide a way to do this in my .NET
application.

Thank you for your help.

Kind Regards,
Steve

Aug 23 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: deko | last post by:
I have a table that contains a bunch of pictures. When the user selects a particular image in a form, I need a way to extract the selected bitmap image (stored in an OLE Object table field) to the...
7
by: Neo Geshel | last post by:
Greetings. I have managed to stitch together an awesome method of posting text along with an image to a database, in a way that allows an unlimited number of previews to ensure that text and...
5
by: Jim Carlock | last post by:
I'm looking to use an image of letters and numbers, whereby I need a way to extract each letter and number to create random strings, then combine/conjoin/meld/mesh/merge/unify/unite the images...
0
by: chandrasena | last post by:
I am willing to extract Image format, Image Version, Image Identification, Image type, Image data format, Compression type etc.., from an image. How can i achieve this in C#. Please Send me the Code.
11
by: maruk2 | last post by:
I downloaded 90-day trial version of Visual Studio 2005 but this thing is only in .img file format and Microsoft does not provide any extraction utility for .img files. According to this page...
4
by: SM | last post by:
Hello, I've created a Unordered list with images using the Javascript DOM, and i want to set up the width and height attributes of the image... The problem is that most images vary in size....
20
by: kosanovic | last post by:
Hello, I'm bad at regular expressions. Would somebody help me: I need to extract all URL to .jpg and .png pictures from a string containing an HTML file (DOM wouldn't work well in what I need). ...
4
by: kurapix | last post by:
Hi there!!! I've been working on recognizing EAN barcodes from images. Yes it's about recognizing barcodes from images but from bars not from the digit with the help of OCR software but with...
1
Thekid
by: Thekid | last post by:
Hi, I have an image similar to a clock, with numbers and letters going around in a circle. I need to extract the numbers and letters from the image and have them print out in a straight line and in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.