473,688 Members | 3,175 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5755
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.com wrote in message
news:%2******** ********@TK2MSF TNGP03.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.pd f"

Thanks for your help!

Regards,
Steve

"Rick" <Ri**@lakevalle yseed.comwrote in message
news:CB******** *************** ***********@mic rosoft.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.com wrote in message
news:%2******** ********@TK2MSF TNGP03.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.StartIn fo.Arguments =
String.Format("-dSAFER -dBATCH -dNOPAUSE -sDEVICE=tiffg3 -sOutputFile=""{ 0}""
""{1}""", Path.ChangeExte nsion(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.comwrot e in message
news:%2******** ********@TK2MSF TNGP05.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.pd f"

Thanks for your help!

Regards,
Steve

"Rick" <Ri**@lakevalle yseed.comwrote in message
news:CB******** *************** ***********@mic rosoft.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.com wrote in message
news:%2******* *********@TK2MS FTNGP03.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**@lakevalle yseed.comwrote in message
news:F4******** *************** ***********@mic rosoft.com...
>I run mine from Net process.start like this:

process.StartIn fo.Arguments =
String.Format("-dSAFER -dBATCH -dNOPAUSE -sDEVICE=tiffg3 -sOutputFile=""{ 0}""
""{1}""", Path.ChangeExte nsion(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.comwrot e in message
news:%2******** ********@TK2MSF TNGP05.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.pd f"

Thanks for your help!

Regards,
Steve

"Rick" <Ri**@lakevalle yseed.comwrote in message
news:CB******* *************** ************@mi crosoft.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.com wrote in message
news:%2****** **********@TK2M SFTNGP03.phx.gb l...
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
applicatio n.

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.comwrot e in message
news:#F******** ******@TK2MSFTN GP05.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.pd f"

Thanks for your help!

Regards,
Steve

"Rick" <Ri**@lakevalle yseed.comwrote in message
news:CB******** *************** ***********@mic rosoft.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.com wrote in message
news:%2******* *********@TK2MS FTNGP03.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
24219
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 file system so the user can do stuff with "somePicture.bmp", for example. Is there an easy way to do this? Thanks in advance.
7
7933
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 image are perfect before submission. This involves converting any uploaded image to a Base64 String and holding that in a hidden form field until either the post gets submitted to the database or the image gets replaced with another one. I...
5
2611
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 into one one image. Is it better to extract each individual letter from one image and then create the new image or is it better to use 36 different images of different names and then create the image from that? And can anyone provide any help in...
0
1386
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
2038
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 (related to another software with at least alternative.iso format) http://msdn.microsoft.com/vstudio/express/support/install/ you have to use 3rd party programs, and the ones listed are not free and charge min $30.
4
4051
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. Here's my question: Knowing the filepath of the image, is it possible to extract the width and height? If yes, how... Thanks Marco
20
14640
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). I've tried: preg_match_all("/.jpg$|.png$/", $htmlfile, $Matches); foreach ($Matches as $match) {
4
11988
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 "Open Computer Vision library" (OpenCV). I haven't been successful yet. Here is my idea at how I should do it : - Image capture
1
9446
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 order from inner circle working out. Here is an example of the image: http://img296.imageshack.us/my.php?image=screenimageqk9.jpg Since the characters in the image will be different each time I am starting with a screenshot, then I think I should...
0
8590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6453
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5807
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4321
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.