PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 14, 2024 10:01 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Jan 26, 2011 3:04 pm 
Offline

Joined: Wed Jan 26, 2011 2:51 pm
Posts: 3
Hi there.

I tried the image export sample from
http://www.pdfsharp.net/wiki/ExportImages-sample.ashx
but it's not working with CMYK images.
The saved images look like negative RGB.

Code:
static void ExportJpegImage(PdfDictionary image, ref int count)
{
  // Fortunately JPEG has native support in PDF and exporting an image is just writing the stream to a file.
  byte[] stream = image.Stream.Value;
  FileStream fs = new FileStream(String.Format("Image{0}.jpeg", count++), FileMode.Create, FileAccess.Write);
  BinaryWriter bw = new BinaryWriter(fs);
  bw.Write(stream);
  bw.Close();
}


best regards!

Edit: ColorSpace Key of the PDFDictionary.Element Property is "34 0 R"


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 26, 2011 4:19 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
asdfgh2 wrote:
Edit: ColorSpace Key of the PDFDictionary.Element Property is "34 0 R"

This is a reference to element 34 in your PDF file.

Acrobat can display negated images (check the "/DECODE" entry of the PDF file).

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 28, 2011 7:09 pm 
Offline

Joined: Wed Jan 26, 2011 2:51 pm
Posts: 3
Thanks for your answer!
how can i access element 34 then? theres no entry in page.elements.
however i am not sure if you understood my question probably:
i want to save images from a pdf as JPG i dont want to save a pdf.

best regards!


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 31, 2011 9:19 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
asdfgh2 wrote:
however i am not sure if you understood my question probably:
i want to save images from a pdf as JPG i dont want to save a pdf.

That's what I understood.
But the reference to object 34 doesn't help those who don't have that PDF file.

When you open the file with PDFsharp, PDFsharp will handle the references for you.

The PDF file contains the JPEG image - and it contains the filter parameters that instruct Adobe Reader how to display the image. Filter parameters can specify that 1 is white and 0 is black - or that 1 is black and 0 is white.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 31, 2011 1:14 pm 
Offline

Joined: Wed Jan 26, 2011 2:51 pm
Posts: 3
ok now i understand :)
So i have to decode the image before saving.
thank you very much!


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 22, 2011 8:54 am 
Offline

Joined: Fri Apr 22, 2011 8:50 am
Posts: 1
Hi,

I've exactly the same problem. Can you post your solution please ?

Thanks.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 33 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