PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Nov 27, 2010 11:03 pm 
Offline

Joined: Sat Nov 27, 2010 10:51 pm
Posts: 3
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.


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 27, 2010 11:16 pm 
Offline

Joined: Sat Nov 27, 2010 10:51 pm
Posts: 3
Sometimes I get the error message: 'Insufficient data for an image'. This isn't true.


Top
 Profile  
Reply with quote  
PostPosted: Wed Dec 01, 2010 8:30 pm 
Offline

Joined: Sat Nov 27, 2010 10:51 pm
Posts: 3
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.


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

All times are UTC


Who is online

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