PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
Adding CMYK TIFF Images http://forum.pdfsharp.de/viewtopic.php?f=2&t=2335 |
Page 1 of 1 |
Author: | w.berger [ Wed Feb 20, 2013 5:06 pm ] |
Post subject: | Adding CMYK TIFF Images |
Hi, I'm trying to add a CMYK TIFF image to a document as follows: Code: var document = new PdfDocument(); document.Options.ColorMode = PdfColorMode.Cmyk; using (var image = CreateImageFromByteArray(tiffData)) { var page = document.AddPage(); page.Size = PageSize.A3; page.Orientation = PageOrientation.Portrait; var gfx = XGraphics.FromPdfPage(page); // maintain aspect ratio double widthScale = page.Width/image.PointWidth; double heightScale = page.Height/image.PointHeight; double scale = Math.Min(widthScale, heightScale); gfx.DrawImage(image, 0, 0, image.PointWidth*scale, image.PointHeight*scale); } CreateImageFromByteArray() is implemented as follows: Code: private static XImage CreateImageFromByteArray(byte[] imageData) { var stream = new MemoryStream(imageData); stream.Write(imageData, 0, imageData.Length); var tiffImage = Image.FromStream(stream); return XImage.FromGdiPlusImage(tiffImage); } Everytime I feed it with the TIFF Image (can be viewed correctly with Windows Photo Viewer), I get the the exception "Image format not supported.", which is thrown in PdfImage.cs, at line 257. What can I do to fix this? I need to use CMYK, since the generated PDF is intended for Printing. The used environment is ASP.NET. Thanks in advance, Wolfgang |
Author: | Thomas Hoevel [ Wed Feb 20, 2013 5:54 pm ] |
Post subject: | Re: Adding CMYK TIFF Images |
Hi! You can try the GDI+ build to see if that works. CMYK JPEG files should work. CMYK TIFF files should also work - we tried a few files we had when we implemented it. If your files work neither with the GDI+ build nor the WPF build, then we would need a sample file to check what Windows makes out of the file. |
Author: | w.berger [ Wed Feb 20, 2013 6:02 pm ] |
Post subject: | Re: Adding CMYK TIFF Images |
Thanks for the quick reply! I forgot to mention that I used the GDI+ build, and I am now trying the WPF variant to see, if this one works. I'll keep you updated! |
Author: | w.berger [ Thu Feb 21, 2013 7:55 am ] |
Post subject: | Re: Adding CMYK TIFF Images |
The WPF build seems to work, thanks for your help! I can send you the problematic TIFFs for testing the GDI+ build, if you want to have them. |
Author: | Thomas Hoevel [ Thu Feb 21, 2013 9:22 am ] |
Post subject: | Re: Adding CMYK TIFF Images |
Glad it works now. If it works with the WPF build, it should be easy to fix for the GDI+ build. I'll have a look at your files. |
Author: | w.berger [ Mon Feb 25, 2013 1:43 pm ] |
Post subject: | Re: Adding CMYK TIFF Images |
Hi, I encountered a new problem with a TIFF (CMYK + Alpha): The WPF build is not able to draw the image and throws the exception: "Image format "Cmyk32" not supported." Does this mean, I cannot use Cmyk32 images, or is there a workaround available? Thanks in advance! |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |