Home : Export a multipage TIFF to a PDF using DotImage in ASP.NET
Q10099 - HOWTO: Export a multipage TIFF to a PDF using DotImage in ASP.NET

Exporting an image to a PDF is a convenient way to print images from a browser, especially a multipage TIFF document.  Most people have Adobe Acrobat installed, and it is multiplatform.

The C# code to export to a PDF image is as follows:

using System.IO;
using System.Drawing;
using Atalasoft.Imaging.Codec.Pdf;
using Atalasoft.Imaging.Codec;
using Atalasoft.Imaging;
using System.IO;

Response.Clear();
Response.ContentType = "application/pdf";

//a hidden input form storing the last opened image
string imageFile = Page.MapPath(".") + "\\" + this.LastOpenedImage.Value;

// Create the PDF.
PdfEncoder pdf = new PdfEncoder();

// Set any properties.
pdf.JpegQuality = 85;
pdf.Metadata = new PdfMetadata("Test PDF", "Atalasoft", "Testing PdfEncoder", "", "", "DotImage", DateTime.Now, DateTime.Now);

// Make each image fit into an 8.5 x 11 inch page (612 x 792 @ 72 DPI).
pdf.SizeMode = PdfPageSizeMode.FitToPage;
pdf.PageSize = new Size(612, 792);

// Make the memory stream to hold the results
using (Stream pdfStream = new MemoryStream())
// Make the FileSystemImageSource that will read the images in to the PdfEncoder
using (FileSystemImageSource images = new FileSystemImageSource(imageFile, true))
{
pdf.Save(pdfStream, images, null);

pdfStream.Seek(0, SeekOrigin.Begin);

byte[] pdfBytes = new byte[pdfStream.Length];
pdfStream.Seek(0, SeekOrigin.Begin);
Response.BinaryWrite(pdfBytes);
}BR>

Response.Flush();
Response.End();

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2017. InstantASP Ltd. All Rights Reserved