tags:

views:

516

answers:

2

Hi All,

I am using iTextSharp to extract images from PDF. However, if the images are CCITT fax decoded, the bitmap creation fails with "Parameter not valid" error.

As PdfReader.GetStreamBytesRaw returns CCITT encoded bytes, bitmap creation fails.

Can someone please help me with decoding CCITT encoded bytes and in turn create a bitmap out of it?

Thanks, Chandru

A: 

I found a workaround to get bitmap from CCITT encoded PDF files.

Ghostscript supports converting PDF files to Tiff. There is a simple C# wrapper available to convert PDF files to jpg files here. http://www.mattephraim.com/blog/2009/01/06/a-simple-c-wrapper-for-ghostscript/ The wrapper can be easily modified to get CCITT compressed Tiff files instead of jpg files. The wrapper supports converting a specific page of PDF to Tiff.

The solution is, convert the specific page of PDF to a temporary tiff file, load the bitmap from the tiff and delete the tiff file.

Chandru

you can get the latest code for the C# Ghostscript wrapper at http://github.com/mephraim/ghostscriptsharp
Matt Ephraim
A: 

but in your answer get resolution and i will get resolution from original image in pdf

jozi