Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143516 | Mar 25,2019 05:07 AM UTC | Apr 14,2020 02:14 PM UTC | ASP.NET Core - EJ 2 | 6 |
![]() |
Tags: PDF |
PdfDocument document = new PdfDocument();
//Load the multi frame TIFF image from the disk
FileStream imageStream = new FileStream("D://TiffImage.tiff", FileMode.Open, FileAccess.Read);
PdfTiffImage tiffImage = new PdfTiffImage(imageStream);
//Get the frame count
int frameCount = tiffImage.FrameCount;
//Access each frame and draw into the page
for (int i = 0; i < frameCount; i++)
{
//Add a section to the PDF document
PdfSection section = document.Sections.Add();
//Set page margins
section.PageSettings.Margins.All = 0;
tiffImage.ActiveFrame = i;
//Create a PDF unit converter instance
PdfUnitConvertor converter = new PdfUnitConvertor();
//Convert to point
Syncfusion.Drawing.SizeF size = converter.ConvertFromPixels(tiffImage.PhysicalDimension, PdfGraphicsUnit.Point);
//Set page orientation
section.PageSettings.Orientation = (size.Width > size.Height) ? PdfPageOrientation.Landscape : PdfPageOrientation.Portrait;
//Set page size
section.PageSettings.Size = size;
//Add a page to the section
PdfPage page = section.Pages.Add();
//Draw TIFF image into the PDF page
page.Graphics.DrawImage(tiffImage, Syncfusion.Drawing.PointF.Empty, size);
}
//Creating the stream object
FileStream fileStream = new FileStream("TiffToPDF.pdf", FileMode.Create, FileAccess.ReadWrite);
//Save and close the PDF document
document.Save(fileStream);
document.Close(true);
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.