PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 1:33 pm

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
 Post subject: How to develop PDFSharp?
PostPosted: Mon Aug 17, 2009 2:30 pm 
Offline

Joined: Mon Aug 17, 2009 1:40 pm
Posts: 1
Hello group

Recently I had to print image in CMYK color space. I didn't find support in WPF version so I wrote my own function that should be called instead of PdfSharp.Pdf.Advanced.PdfImage.ReadTrueColorMemoryBitmap (code below). Is there any way to extend the basic functionality? The PdfImage class is sealed.
BTW BitmapSource.CopyPixels requires SecurityPermissionFlag.UnmanagedCode
Code:
private void readCmykMemoryBitmap() {
   Debug.Assert(this.image.wpfImage.Format == PixelFormats.Cmyk32,"Only CMYK support");
   int _nOfChannels = 4;

   int height = this.image.PixelHeight;
   int width = this.image.PixelWidth;

   byte[] _destImageData = new byte[_nOfChannels * width * height];

   int _stride = _nOfChannels * width;
   this.image.wpfImage.CopyPixels(_destImageData,_stride,0);

   FlateDecode fd = new FlateDecode();

   byte[] imageDataCompressed = fd.Encode(_destImageData);

   Stream = new PdfStream(imageDataCompressed,this);
   Elements[Keys.Length] = new PdfInteger(imageDataCompressed.Length);
   Elements[Keys.Filter] = new PdfName("/FlateDecode");
   Elements[Keys.Width] = new PdfInteger(width);
   Elements[Keys.Height] = new PdfInteger(height);
   Elements[Keys.BitsPerComponent] = new PdfInteger(8);
   Elements[Keys.ColorSpace] = new PdfName("/DeviceCMYK");
   if(image.Interpolate)
      Elements[Keys.Interpolate] = PdfBoolean.True;
}


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 10, 2009 3:39 pm 
Offline

Joined: Sat Oct 10, 2009 3:08 pm
Posts: 1
I used your code to embed Tiff with CMYK color into a pdf.
But after I generate and saved the pdf, and then open it, acrobat reader report error!
Would you please give me hand?
Thanks,
johnsonroom@gmail.com.


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: Bing [Bot], Google [Bot] and 420 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