A way to find out whether a pdf file is image based

General discussions about GdPicture.NET.
Post Reply
charuvas1
Posts: 38
Joined: Tue Dec 02, 2008 1:49 pm

A way to find out whether a pdf file is image based

Post by charuvas1 » Sat Apr 24, 2010 2:26 pm

Hi,

Is there a way to find out whether a pdf file is image based or not? i.e. whether this pdf file has image or text data?

Thank you
charu

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: A way to find out whether a pdf file is image based

Post by Loïc » Tue Apr 27, 2010 11:52 am

Hi,

here an idea:

- Open the PDF
- Extract text
- Get Image count

If Image count = 1 and text is empty you have lot of chance to have "image based" PDF.

Kind regards,

Loïc

charuvas1
Posts: 38
Joined: Tue Dec 02, 2008 1:49 pm

Re: A way to find out whether a pdf file is image based

Post by charuvas1 » Wed Apr 28, 2010 11:49 am

Hi,

As you said I use your functions to know file is image base or not. But it gives me execption if PDF file is a fallible form. It throw exception.
Exception message:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.


My code is as below:

Code: Select all

Dim oGdPictureImaging As New GdPicture.GdPictureImaging
 oGdPictureImaging.SetLicenseNumber("xxxxx")

 Dim PdfID As Integer = oGdPictureImaging.PdfReaderLoadFromFile(InputFilePath)
       If PdfID > 0 Then
                Dim imgCount As Integer = oGdPictureImaging.PdfReaderGetImageCount(PdfID)
                Dim fleText As String = oGdPictureImaging.PdfReaderGetPageText(PdfID)

                If imgCount >= 1 And fleText = "" Then
                    MsgBox("file is image base")
                Else
                    MsgBox("file is text base")
                End If
     End If
oGdPictureImaging.ReleaseGdPictureImage(PdfID)

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: A way to find out whether a pdf file is image based

Post by Loïc » Wed Apr 28, 2010 4:41 pm

Hi,

You have first to select a page.

Please, make a call to PdfReaderSelectPage before using PdfReaderGetImageCount.

Kind regards,

Loïc

charuvas1
Posts: 38
Joined: Tue Dec 02, 2008 1:49 pm

Re: A way to find out whether a pdf file is image based

Post by charuvas1 » Thu Apr 29, 2010 12:15 pm

Hi,

As you said i call oGdPictureImaging.PdfReaderSelectPage(PdfID, 1) 'Select Page1
before PdfReaderGetImageCount. But I get an exception which i explain earlier.
It occurs only in fallible form PDF.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: A way to find out whether a pdf file is image based

Post by Loïc » Thu Apr 29, 2010 2:55 pm

Hi,

Please attach PDF which cause this error for investigation.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests