PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Oct 25, 2007 9:10 am 
Offline

Joined: Thu Oct 25, 2007 9:06 am
Posts: 3
Hi,

Can any one help me in creating pdf using pdfsharp for multipage tiff file. single page i was able to do. Please help me for mutipage tiff


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Oct 25, 2007 10:36 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
You can specify which page you want if you load an Image from a TIFF file.
You use this Image like any other Image with PDFsharp.

The VS help file contains sample code on multi-page TIFF files.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Oct 26, 2007 12:11 pm 
Offline

Joined: Thu Oct 25, 2007 9:06 am
Posts: 3
Hi Thomas,

Can you please paste me the code for mutitiff as i was not able find to split the mutipage i can only get the count of no of pages available in multitiff file.

Where in PDF Sharp i can specifiy the image no.

currently i am using

PdfDocument outputDocument = new PdfDocument();
//
// // Open the document to import pages from it.
PdfDocument inputDocument = PdfReader.Open(outfilename, PdfDocumentOpenMode.Import);
string infilename = @"002.tif";
XImage image = XImage.FromFile(infilename);
// // Add new page to output document.
System.Drawing.Bitmap bm = new System.Drawing.Bitmap(@"001.tif");
total = bm.GetFrameCount(FrameDimension.Page);
for(Int32 k=0; k<total; k++)
{
//bm.SelectActiveFrame(FrameDimension.Page, k);
PdfPage page1= outputDocument.AddPage();
//
// Get Image width, Height and Resolution and Set output document Width and Height in Inches
page1.Width = XUnit.FromInch(image.Width/ image.HorizontalResolution);
page1.Height = XUnit.FromInch(image.Height/ image.VerticalResolution);
XGraphics gfx = XGraphics.FromPdfPage(page1, XGraphicsPdfPageOptions.Append);
gfx.DrawImage(image, 0, 0);
gfx.Dispose();
image.Dispose();
page1.Close();
}

Please Thomas if you can help me it would be great. i have 215 page tiff file to be converted to pdf. All the tiff files are of these many pages or more.

Thanks in Advance.

Regards,
Rajesh


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 29, 2007 9:46 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi, Rajesh!

A small detail was missing in your code: you have to use the image you called SelectActiveFrame for.

Code:
      Bitmap bm = new Bitmap(infilename);
      int total = bm.GetFrameCount(FrameDimension.Page);
      for (Int32 k = 0; k < total; k++)
      {
        Bitmap bm2 = new Bitmap(infilename);
        bm2.SelectActiveFrame(FrameDimension.Page, k);
        XImage image = XImage.FromGdiPlusImage(bm2);
        PdfPage page1 = document.AddPage();
        //
        // Get Image width, Height and Resolution and Set output document Width and Height in Inches
        page1.Width = XUnit.FromInch(image.Width / image.HorizontalResolution);
        page1.Height = XUnit.FromInch(image.Height / image.VerticalResolution);
        gfx = XGraphics.FromPdfPage(page1, XGraphicsPdfPageOptions.Append);
        gfx.DrawImage(image, 0, 0);
        gfx.Dispose();
        image.Dispose();
        page1.Close();
        bm2.Dispose();
      }

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Oct 29, 2007 10:11 am 
Offline

Joined: Thu Oct 25, 2007 9:06 am
Posts: 3
Hi Thomas,

Thanks a lot that worked for me. Great help,

Thanks,
Regards,
Rajesh


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 340 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