←Select platform

GetThumbnailsGrid Method

Summary

Gets an image that contains one or more page thumbnails.

Syntax
C#
C++/CLI
Java
Python
public RasterImage GetThumbnailsGrid( 
   int firstPageNumber, 
   int lastPageNumber, 
   int maximumGridWidth 
) 
public: 
   RasterImage^ GetThumbnailsGrid( 
      int firstPageNumber, 
      int lastPageNumber, 
      int maximumGridWidth 
   ) 
public RasterImage getThumbnailsGrid(int firstPageNumber, int lastPageNumber, int maximumGridWidth) 
def GetThumbnailsGrid(self,firstPageNumber,lastPageNumber,maximumGridWidth): 

Parameters

firstPageNumber

1-based number of the first page number in the document.

lastPageNumber

1-based number of the last page number in the document.

maximumGridWidth

The maximum width of the grid in pixels.

Return Value

A raster image object that contains the thumbnails in a grid layout.

Remarks

Thumbnail grids can be used to obtain the thumbnails of one or more pages in a single call. The result image will contain the images in a grid layout, left to right by row; each image will be of size thumbnailPixelSize. The grid width will be less than or equal to maximumGridWidth in pixels. The number of columns is calculated by dividing maximumGridWidth by the thumbnailPixelSize width. The grid height and number of rows is determined by the columns and total number of images to obtain.

The total number of images to obtain is calculated from firstPageNumber and lastPageNumber. If lastPageNumber is 0 or -1, the last page number in the document will be used; in this case, all pages from firstPageNumber to the end of the document will be returned in the thumbnail grid.

The LEADTOOLS Document Viewer can use GetThumbnailsGrid to speed up obtaining the thumbnails of the pages in the document instead of iterating each page and calling DocumentPage.GetThumbnailImage.

Note that this method does not update the cache.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Document.Writer; 
 
using Leadtools.Document; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
using Leadtools.Barcode; 
using Leadtools.Document.Converter; 
 
public void GetThumbnailsGridExample() 
{ 
   var options = new LoadDocumentOptions(); 
   using (var document = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf"), options)) 
   { 
      // GetThumbnailsGrid(int firstPageNumber, int lastPageNumber, int maximumGridWidth) 
      document.Images.GetThumbnailsGrid(1, 5, 300); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.FileOutputStream; 
import java.io.IOException; 
import java.net.MalformedURLException; 
import java.net.URI; 
import java.net.URISyntaxException; 
import java.net.URL; 
import java.nio.file.Files; 
import java.nio.file.Paths; 
import java.util.ArrayList; 
import java.util.Calendar; 
import java.util.List; 
import java.util.concurrent.Callable; 
import java.util.concurrent.ExecutorService; 
import java.util.concurrent.Executors; 
import java.util.concurrent.Future; 
import java.util.regex.Pattern; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.annotations.engine.*; 
import leadtools.barcode.*; 
import leadtools.caching.*; 
import leadtools.codecs.*; 
import leadtools.document.*; 
import leadtools.document.DocumentMimeTypes.UserGetDocumentStatusHandler; 
import leadtools.document.converter.*; 
import leadtools.document.writer.*; 
import leadtools.ocr.*; 
 
 
public void getDocumentCacheInfoExampleetThumbnailsGridExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   LoadDocumentOptions options = new LoadDocumentOptions(); 
   LEADDocument document = DocumentFactory.loadFromFile(combine(LEAD_VARS_IMAGES_DIR, "Leadtools.pdf"), options); 
   // GetThumbnailsGrid(int firstPageNumber, int lastPageNumber, int 
   // maximumGridWidth) 
   RasterImage grid = document.getImages().getThumbnailsGrid(1, 5, 300); 
   assertTrue(grid != null); 
} 

Consider the following parameters:

In this example, we will load 10 images (specified by firstPageNumber and lastPageNumber). Each image will be 100 pixels by 100 pixels. Because maximumGridWidth is 300, and the width of a single image is 100, we will have 3 columns. Because we have 10 images and 3 columns, we can calculate that we will need four rows. Our images will look like this:

Full Image - 3 columns, 4 rows 
+----+----+----+ 
| 1  | 2  | 3  | 
+----+----+----+ 
| 4  | 5  | 6  | 
+----+----+----+ 
| 7  | 8  | 9  | 
+----+----+----+ 
| 10 | __ | __ | 
+----+----+----+ 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.