Skip to content

Commit 202a659

Browse files
Merge pull request #1108 from telerik/new-kb-display-select-pdf-thumbnails-dotnet-maui-18c1f78958e94d5fbb93ac258afa96cd
Added new kb article display-select-pdf-thumbnails-dotnet-maui
2 parents 1c872d6 + f6654cc commit 202a659

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Displaying Thumbnails of Multiple PDFs in a Single View with .NET MAUI
3+
description: Learn how to generate and display thumbnails for the first page of multiple PDF files in a single list box view, and open the selected PDF in a PDFViewer for .NET MAUI.
4+
type: how-to
5+
page_title: How to Display and Select PDF Thumbnails in a .NET MAUI Application
6+
slug: display-select-pdf-thumbnails-dotnet-maui
7+
tags: pdfviewer, .net maui, pdf, thumbnails, list box, pdf processing
8+
res_type: kb
9+
---
10+
11+
## Environment
12+
13+
| Version | Product | Author |
14+
| --- | --- | ---- |
15+
| 10.0.0 | Telerik UI for .NET MAUI PDF Viewer | [Dobrinka Yordanova](https://www.telerik.com/blogs/author/dobrinka-yordanova) |
16+
17+
18+
## Description
19+
20+
I need a way to display the first page of multiple PDF files as thumbnails. Then display the thumbnails in a list. When a thumbnail is clicked, the respective full PDF document should open in a separate PDF Viewer.
21+
22+
This knowledge base article also answers the following questions:
23+
- How can I display thumbnails of PDF files in a list using .NET MAUI?
24+
- How do I open a PDF in a PDFViewer when its thumbnail is clicked in .NET MAUI?
25+
- How to generate and use thumbnails of PDF pages in a .NET MAUI application?
26+
27+
## Solution
28+
29+
To achieve this, follow the steps in the [Generating and Displaying PDF Thumbnails](#generating-and-displaying-pdf-thumbnails) and [Loading PDF Documents in a PDF Viewer](#loading-pdf-documents-in-a-pdf-viewer) sections.
30+
31+
### Generating and Displaying PDF Thumbnails
32+
33+
1. Use the Telerik PDF Processing library ([RadPdfProcessing](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/overview)) to convert the first page of each PDF file into an image thumbnail. Refer to this blog post for guidance: [Turn PDF Pages Into Images With PdfProcessing](https://www.telerik.com/blogs/turn-pdf-pages-images-pdfprocessing).
34+
35+
2. Iterate through each PDF file, extract the first page, and save it as an image. Manage the storage of these images appropriately on the device.
36+
37+
3. Create a collection that contains the image paths and the PDF file names. Bind this collection to a list control in your .NET MAUI application. Use an `<Image/>` element to display each thumbnail and a `<Label>` to show the document name.
38+
39+
3.1. Define the `RadCollectionView` in XAML:
40+
41+
```xaml
42+
<telerik:RadCollectionView ItemsSource="{Binding ListOfDocuments}"
43+
ItemTapped="RadCollectionView_ItemTapped">
44+
<telerik:RadCollectionView.ItemTemplate>
45+
<DataTemplate>
46+
<VerticalStackLayout>
47+
<Image Source="{Binding YourImage}" />
48+
<Label Text="{Binding YourPdfDocumentName}" />
49+
</VerticalStackLayout>
50+
</DataTemplate>
51+
</telerik:RadCollectionView.ItemTemplate>
52+
</telerik:RadCollectionView>
53+
```
54+
55+
3.2. Implement the `ItemTapped` event to handle thumbnail selection and navigate to a new page where the PDF Viewer is defined. Pass the selected PDF document to the `PdfViewer.Source` property.
56+
57+
### Loading PDF Documents in a PDF Viewer
58+
59+
Use the [PDF Viewer for .NET MAUI](https://docs.telerik.com/devtools/maui/controls/pdfviewer/display-documents) to display the selected PDF document. The PDF Viewer has a `Source` property, which you should set to the selected PDF document during navigation.
60+
61+
```csharp
62+
// In the navigation logic from the list box to the PDFViewer page
63+
pdfViewer.Source = selectedPdfDocumentPath;
64+
```
65+
66+
## See Also
67+
68+
- [RadPdfProcessing Overview](https://docs.telerik.com/devtools/document-processing/libraries/radpdfprocessing/overview)
69+
- [Displaying Documents in PDF Viewer for .NET MAUI](https://docs.telerik.com/devtools/maui/controls/pdfviewer/display-documents)
70+
- [Turn PDF Pages Into Images With PdfProcessing Blog Post](https://www.telerik.com/blogs/turn-pdf-pages-images-pdfprocessing)

0 commit comments

Comments
 (0)