View previous topic :: View next topic |
Author |
Message |
Rajesh
Joined: 25 Oct 2007 Posts: 3
|
Posted: Thu Oct 25, 2007 9:10 am Post subject: MultiPage Tiff file to PDF |
|
|
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 |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Thu Oct 25, 2007 10:36 am Post subject: |
|
|
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 |
|
Back to top |
|
|
Rajesh
Joined: 25 Oct 2007 Posts: 3
|
Posted: Fri Oct 26, 2007 12:11 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Mon Oct 29, 2007 9:46 am Post subject: |
|
|
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 |
|
Back to top |
|
|
Rajesh
Joined: 25 Oct 2007 Posts: 3
|
Posted: Mon Oct 29, 2007 10:11 am Post subject: |
|
|
Hi Thomas,
Thanks a lot that worked for me. Great help,
Thanks,
Regards,
Rajesh |
|
Back to top |
|
|
|