Page 1 of 1
A way to find out whether a pdf file is image based
Posted: Sat Apr 24, 2010 2:26 pm
by charuvas1
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
Re: A way to find out whether a pdf file is image based
Posted: Tue Apr 27, 2010 11:52 am
by Loïc
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
Re: A way to find out whether a pdf file is image based
Posted: Wed Apr 28, 2010 11:49 am
by charuvas1
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)
Re: A way to find out whether a pdf file is image based
Posted: Wed Apr 28, 2010 4:41 pm
by Loïc
Hi,
You have first to select a page.
Please, make a call to PdfReaderSelectPage before using PdfReaderGetImageCount.
Kind regards,
Loïc
Re: A way to find out whether a pdf file is image based
Posted: Thu Apr 29, 2010 12:15 pm
by charuvas1
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.
Re: A way to find out whether a pdf file is image based
Posted: Thu Apr 29, 2010 2:55 pm
by Loïc
Hi,
Please attach PDF which cause this error for investigation.
Kind regards,
Loïc