Q:
Does PDFNet SDK support opening a multi-page TIF and converting to
PDF? I ran the PDFView sample project and the viewer only displayed
the initial TIF page.
- Can multi-page TIFs be opened by the viewer?
- Can multi-page TIFs be programmatically converted to PDF?
----
A:
You can use PDFNet SDK both for viewing multi-page TIFF and for
programmatic conversion of multi-page TIFF to PDF.
PDFView (C# or VB.NET) sample project (http://www.pdftron.com/net/
samplecode.html#PDFView) is using OpenImage utility method (in
PDFViewForm.cs) to convert and TIF, JPEG, PNG, and other image formats
to PDF. Currently the sample code imports only the first frame from
the multi-page TIFF however you could extend the functionality using
standard .NET API used to read multi-page TIFF.
For example of how to extract frames from multi-page TIFF you may want
to search for SelectActiveFrame() in MSDN. Also you may find the
following article useful: http://www.bobpowell.net/addframes.htm
// Opens a TIFF image and extracts the frames
private void DoOpen(string tif_filename) {
FileStream fs=File.Open(filename,FileMode.Open,FileAccess.Read);
Bitmap bm=(Bitmap)Bitmap.FromStream(fs);
for(int i=0; i<bm.GetFrameCount(FrameDimension.Page); i++) {
bm.SelectActiveFrame(FrameDimension.Page, i);
Bitmap temp=new Bitmap(bm.Width,bm.Height);
Graphics g=Graphics.FromImage(temp);
g.InterpolationMode=InterpolationMode.NearestNeighbor;
g.DrawImageUnscaled(bm,0,0);
g.Dispose();
... AddFrameToPDF(temp);
}
}
fs.Close();
bm.Dispose();
}