PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Pages missing after multipage tiff conversion
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1444
Page 1 of 1

Author:  Veronica [ Sat Nov 27, 2010 11:03 pm ]
Post subject:  Pages missing after multipage tiff conversion

Hello, Thank you for helping me with this problem.

I'm trying to convert multipage tiffs to a multipage pdf. It works sometimes but some of the pages are blank when converting a file with many pages. It seems to miss more pages the larger the files. The conversion doesn't always miss the same pages and I can convert one of the blank pages when it is by itself.

Below is the code I am using. The converter is a dataservice within a silverlight app. All is well, except for the blank pages.

Stream imageStream = new FileStream(newTiffTempPath, FileMode.Open, FileAccess.Read,
FileShare.Read);

var decodeTiff = new TiffBitmapDecoder(imageStream, BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.Default);


var doc = new PdfDocument();
// convert each page of the Tiff file to a pdf frame)
for (int x = 0; x < decodeTiff.Frames.Count; ++x)
{
PdfPage pg = new PdfPage(); :wink:
pg.Size = PdfSharp.PageSize.Letter;
pg.width = (int)decodeTiff.Frames[x].Width;
pg height = (int)decodeTiff.Frames[x].Height;

XGraphics xgr = XGraphics.FromPdfPage(doc.Pages.Add(pg));
XImage img = XImage.FromBitmapSource(decodeTiff.Frames[x]);
xgr.DrawImage(img, 0, 0,);
}
doc.Save(destinationPath);
doc.Close();

Thanks again
Veronica.

Author:  Veronica [ Sat Nov 27, 2010 11:16 pm ]
Post subject:  Re: Pages missing after multipage tiff conversion

Sometimes I get the error message: 'Insufficient data for an image'. This isn't true.

Author:  Veronica [ Wed Dec 01, 2010 8:30 pm ]
Post subject:  Re: Pages missing after multipage tiff conversion

We have fixed our problem. We broke the multipage tiff into single pages and saved each page to disk. We then looped through reading each file using the XImage.FromFile method and it all pages were converted properly.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/