public RasterImage GetThumbnail(
RasterCodecs codecs,
int pageNumber,
int thumbnailWidth,
int thumbnailHeight
)
Public Function GetThumbnail( _
ByVal codecs As RasterCodecs, _
ByVal pageNumber As Integer, _
ByVal thumbnailWidth As Integer, _
ByVal thumbnailHeight As Integer _
) As RasterImage
public RasterImage getThumbnail(
RasterCodecs codecs,
int pageNumber,
int thumbnailWidth,
int thumbnailHeight
);
public:
RasterImage^ GetThumbnail(
RasterCodecs^ codecs,
int pageNumber,
int thumbnailWidth,
int thumbnailHeight
)
codecs
An optional Leadtools.Codecs.RasterCodecs to use when reading the page. If you pass a null reference, then this method will internally create a new Leadtools.Codecs.RasterCodecs object and dispose before it returns.
pageNumber
The 1-based page number. Must be greater than or equal to 1 and less than or equal to the total number of pages in the document (Pages.Count). Use the special value of -1 to represent the last page in the document.
thumbnailWidth
The desired maximum width of the thumbnail image in pixels. Must be greater than 32.
thumbnailHeight
The desired maximum height of the thumbnail image in pixels. Must be greater than 32.
A new Leadtools.RasterImage that is the thumbnail image.
If the page width and height is less than thumbnailWidth and thumbnailHeight, then this method returns an in the original size.
If the page width or height is greater than thumbnailWidth and thumbnailHeight, then this method will return the biggest thumbnail it can fit into the dimensions specified by thumbnailWidth and thumbnailHeight, keeping the original image aspect ratio.
The result image will always have 24 bits per pixel and a resolution of 96 by 96 regardless of the value of Resolution set in this PDFDocument and will never return a thumbnail bigger than the original page size in pixels.
This method uses Leadtools.RasterImage.CalculatePaintModeRectangle(System.Int32,System.Int32,Leadtools.LeadRect,Leadtools.RasterPaintSizeMode,Leadtools.RasterPaintAlignMode,Leadtools.RasterPaintAlignMode) to calculate the thumbnail size and then the RasterCodecs.Load resize method to load the thumbnail with RasterSizeFlags.Resample will be used as the flags parameter.
Since a Leadtools.Codecs.RasterCodecs object is required by this method, you can either pass one through the codecs parameter and the method will use this object to load the page. This is helpful if you need to change the default Leadtools.Codecs.RasterCodecs load options or subscribe to any of the events that will occur during loading. If none of that is required, you can simply pass null for the codecs parameter and this method will internally create, use and dispose a temporary Leadtools.Codecs.RasterCodecs object.
To get a render of the full size of any page in a PDF document, use GetPageImage and GetPageSvg(RasterCodecs,Int32,CodecsLoadSvgOptions) to get an SVG document of the page.
This example will get thumbnails of a PDF file and add them to a LEADTOOLS Raster Image List control.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls;
using Leadtools.Pdf;
using Leadtools.Svg;
using Leadtools.WinForms;
public void PDFDocumentGetThumbnailExample(RasterImageList imageList)
{
string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf");
// Open the document
using (PDFDocument document = new PDFDocument(pdfFileName))
{
using (RasterCodecs codecs = new RasterCodecs())
{
// For each page...
for (int i = 1; i <= document.Pages.Count; i++)
{
// Get the thumbnail of the page
RasterImage image = document.GetThumbnail(codecs, i, 128, 128);
// Add it to the image list
RasterImageListItem item = new RasterImageListItem(image, 1, "Page " + i.ToString());
imageList.Items.Add(item);
}
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Controls
Imports Leadtools.Pdf
Imports Leadtools.Svg
Imports Leadtools.WinForms
Public Sub PDFDocumentGetThumbnailExample(ByVal imageList As RasterImageList)
Dim pdfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf")
' Open the document
Using document As PDFDocument = New PDFDocument(pdfFileName)
Using codecs As RasterCodecs = New RasterCodecs()
' For each page...
Dim i As Integer = 1
Do While i <= document.Pages.Count
' Get the thumbnail of the page
Dim image As RasterImage = document.GetThumbnail(codecs, i, 128, 128)
' Add it to the image list
Dim item As RasterImageListItem = New RasterImageListItem(image, 1, "Page " & i.ToString())
imageList.Items.Add(item)
i += 1
Loop
End Using
End Using
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"
End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document