PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Problem when add color multi page Tiff to PDF https://forum.pdfsharp.net/viewtopic.php?f=2&t=3620 |
Page 1 of 1 |
Author: | Liliya [ Thu Jul 06, 2017 11:12 am ] |
Post subject: | Problem when add color multi page Tiff to PDF |
Hi, I use your component for building PDP from a set of images and other pdf files. Unfortunately arose a problem with files Tiff. Your component perfectly working with multi-page monochrome tiffs. However, when trying to use a color multipage Tiff, to the PDF is added 1 gray blank page instead of multi-page block. Question: Is there a solution for color, multi-page TIFF? Here is the code I'm using. Code: using (Image MyImage = Image.FromFile(pdfPart.Value))
{ for (int PageIndex = 0; PageIndex < MyImage.GetFrameCount(FrameDimension.Page); PageIndex++) { MyImage.SelectActiveFrame(FrameDimension.Page, PageIndex); var stream = new System.IO.MemoryStream(); MyImage.Save(stream, ImageFormat.Tiff); stream.Position = 0; XImage img = XImage.FromStream(stream); var page = new PdfPage(); if (img.PixelWidth > img.PixelHeight) page.Orientation = PdfSharp.PageOrientation.Landscape; else page.Orientation = PdfSharp.PageOrientation.Portrait; outputDocument.AddPage(page); using (XGraphics xgr = XGraphics.FromPdfPage(outputDocument.Pages[targetPageIndx])) { xgr.DrawImage(img, 0, 0); } targetPageIndx++; } } |
Author: | Thomas Hoevel [ Thu Jul 06, 2017 12:59 pm ] |
Post subject: | Re: Problem when add color multi page Tiff to PDF |
Hi! Instead of calling "Save" and "FromStream", you can call "DrawImage" directly for your "MyImage" object (provided you use the GDI+ build of PDFsharp). See also: viewtopic.php?f=2&t=832 |
Author: | Liliya [ Sun Jul 09, 2017 9:18 am ] |
Post subject: | Re: Problem when add color multi page Tiff to PDF |
Thanks for the answer. I changed the code, but the result has not changed. Tiff monochrome + multipage is converted into PDF, Tiff colored + multi-page is not converted. I did a search on the форум topics Quote: "The current version of PDFsharp relies on Windows / .NET to read images." This provided me an answer, since Windows also cannot read these images. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |