PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jul 01, 2024 8:20 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Feb 11, 2010 11:24 pm 
Offline

Joined: Thu Feb 11, 2010 11:01 pm
Posts: 1
I create a 1 page PDF that contains a full page JPG image. I can open and view that PDF file with Adobe. Problem is, I cannot extract the image out of the PDF using PdfSharp.

The problem is that in the InitializeJpeg method in PdfImage, a PdfArray object is created holding two PdfName objects. PdfName("/FlateDecode") and PdfName("/DCTDecode").

In the sample code for reading an image from a PDF, the following code does not work when the /Filter key contains a PdfArray value:
filter = image.Elements.GetName("/Filter");

switch (filter)
{
case "/DCTDecode":
ExportJpegImage(image, ref count, InImagePath);
break;

case "/FlateDecode":
ExportAsPngImage(image, ref count, InImagePath );
break;
}

I made a code change to InitializeJpeg that fixes the problem for me. The following code is always run. No matter the length of imageDataCompressed:
Stream = new PdfStream(imageBits, this);
Elements[Keys.Length] = new PdfInteger(streamLength);
Elements[Keys.Filter] = new PdfName("/DCTDecode");

Only, I don't understand why I can't write as "/FlateDecode". The Adobe PDF reader rejects the PDF file created this way.

Thanks,


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 16, 2010 10:43 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
The Export Images sample is not prepared for images that are compressed twice.
In your case you must call the FlateDecoder to get a JPEG file.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group