Our support team recently worked with a customer who was having issues loading and displaying a 200-page TIFF file. Because each page of the TIFF was stored as a separate file, the size of the document was very large and it was taking too long for each page to display in the viewer. LEAD to the rescue! Using the LEADTOOLS Document Web Viewer
and this simple code below, you can easily load various files into a single TIFF and the viewer takes care of rendering all of them in no time.
The Case of the Multipage TIFF
Using LEADTOOLS, we create one multipage TIFF file in memory from the various different files and return the single document to the viewer, speeding everything up so that each page is displayed very quickly. Working with this specific customer’s file, they saw an 80% increase in display speed! Our support agent also made sure factors like formats, compression, bit depth, page size, DPI, and orientation wouldn’t affect the speed.The LEADTOOLS Document Web Viewer is able to render pages with different sizes and DPI’s without any special processing. You can see how it renders various page sizes by taking a look at our Viewer Styles Demo
View Multipage Files in a Single Document
In the code below, we added various sized items to represent each page.
MemoryStream ms = new MemoryStream();
using (RasterCodecs codecs = new RasterCodecs())
for (int i = 0; i < filenames.Length; i++)
int TotalPages = codecs.GetTotalPages(filenames[i]);
for (int pageNumber = 1; pageNumber <= TotalPages; pageNumber++)
image = codecs.Load(filenames[i], pageNumber);
codecs.Save(image, ms, File_GetRasterTifFormat(image.BitsPerPixel), 0, 1, 1, -1, CodecsSavePageMode.Append);
ms.Position = 0;
return DocumentFactory.LoadFromStream(ms, options);
// Returns best compression based on the bits per pixel of the image
private static RasterImageFormat File_GetRasterTifFormat(int BitsPerPixel)
if (BitsPerPixel == 1)
else if( BitsPerPixel == 24)
Download our Free Evaluation today!
With our 60-day evaluation, you can test all the features and actually program
before a purchase is even made. Gain access to our
extensive documentation, sample source code,
Our support team is here to help! Contact our support team for free technical