Exporting pages as images in UWP PDF Viewer (SfPdfViewer)
14 Nov 20236 minutes to read
The SfPdfViewer allow user to export page of the PDF document as an Image. Here ‘buffer’ is the byte array read from the PDF file either using FileOpenPicker or from Assets folder, as illustrated in the Viewing PDF section.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(buffer);
pdfViewer.LoadDocument(loadedDocument);
//Exports the second page of the PDF document as an Image.
Image pageImg = pdfViewer.GetPage(2);
Dim loadedDocument As New PdfLoadedDocument(Buffer)
pdfViewer.LoadDocument(loadedDocument)
'Exports the second page of the PDF document as an Image.
Dim pageImg As Image = pdfViewer.GetPage(2)
To export a single page of the PDF document as an Image with custom zoom factor, use the below code.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(buffer);
pdfViewer.LoadDocument(loadedDocument);
//Exports the second page of the PDF document as an Image 300% magnified.
Image pageImg = pdfViewer.GetPage(2, 300);
Dim loadedDocument As New PdfLoadedDocument(Buffer)
pdfViewer.LoadDocument(loadedDocument)
'Exports the second page of the PDF document as an Image 300% magnified.
Dim pageImg As Image = pdfViewer.GetPage(2, 300)
The following code explains how to export multiple pages as images.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(buffer);
pdfViewer.LoadDocument(loadedDocument);
//Exports the pages between start and end page index as image array.
Image[] pageImgCollection = pdfViewer.GetPages(0, 5);
Dim loadedDocument As New PdfLoadedDocument(Buffer)
pdfViewer.LoadDocument(loadedDocument)
'Exports the pages between start and end page index as image array.
Dim pageImgCollection As Image() = pdfViewer.GetPages(0, 5)
To export multiple pages as images with custom magnification factor, please follow the below code.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(buffer);
pdfViewer.LoadDocument(loadedDocument);
//Exports the pages between start and end index as image array in the mentioned zoom factor.
Image[] pageImgCollection = pdfViewer.GetPages(0, 5, 200);
Dim loadedDocument As New PdfLoadedDocument(Buffer)
pdfViewer.LoadDocument(loadedDocument)
'Exports the pages between start and end index as image array in the mentioned zoom factor.
Dim pageImgCollection As Image() = pdfViewer.GetPage(0, 5, 200)
The SfPdfViewer allows the user to export pages of the PDF document as image stream to save the image in the disk.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(buffer);
pdfViewer.LoadDocument(loadedDocument);
//Exports the second page of the PDF document as an Image.
Stream imageStream = pdfViewer.ExportAsImage(2);
Dim loadedDocument As New PdfLoadedDocument(Buffer)
pdfViewer.LoadDocument(loadedDocument)
'Exports the second page of the PDF document as an Image.
Dim imageStream As Stream = pdfViewer.ExportAsImage(2)
To export page of PDF document as image stream with customized zoom factor, use the below code.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(buffer);
pdfViewer.LoadDocument(loadedDocument);
//Exports the second page of the PDF document as an Image 300% magnified.
Stream imageStream = pdfViewer.ExportAsImage(2, 300);
Dim loadedDocument As New PdfLoadedDocument(Buffer)
pdfViewer.LoadDocument(loadedDocument)
'Exports the second page of the PDF document as an Image 300% magnified.
Dim imageStream As Stream = pdfViewer.ExportAsImage(2, 300)
To export pages of PDF document as List of image streams, use the below code.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(buffer);
pdfViewer.LoadDocument(loadedDocument);
//Exports the pages between start and end index as image array.
List<Stream> listOfImageStream = pdfViewer.ExportAsImage(0, 5);
Dim loadedDocument As New PdfLoadedDocument(Buffer)
pdfViewer.LoadDocument(loadedDocument)
'Exports the pages between start and end index as image array.
Dim listOfImageStream As List(Of Stream) = pdfViewer.ExportAsImage(0, 5)
To export pages of PDF document as list of image streams with custom zoom factor follow the below code.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(buffer);
pdfViewer.LoadDocument(loadedDocument);
//Exports the pages between start and end index as image array.
List<Stream> listOfImageStream = pdfViewer.ExportAsImage(0, 5, 200);
Dim loadedDocument As New PdfLoadedDocument(Buffer)
pdfViewer.LoadDocument(loadedDocument)
'Exports the pages between start and end index as image array.
Dim listOfImageStream As List(Of Stream) = pdfViewer.ExportAsImage(0, 5, 200)