Exporting PDF

Exporting PDFs as Raster Images

Essential PDF Viewer allows selected pages to be exported as raster images. Exporting can be done using the ExportAsImage method. This option helps to convert a PDF into an image.

//Initialize PDF Viewer.

PdfViewerControl pdfViewer1 = new PdfViewerControl();

//Load the PDF.


Bitmap img = pdfViewer1.ExportAsImage(0);

// Save the image.

img.Save("Sample.png", ImageFormat.Png);
'Initialize PDF Viewer.

Private pdfViewer1 As New PdfViewerControl()

'Load the PDF.


Dim img As Bitmap = pdfViewer1.ExportAsImage(0)

' Save the image.

img.Save("Sample.png", ImageFormat.Png)

You can also specify the page range instead of converting each page.

Bitmap[] img = pdfViewer1.ExportAsImage(0, 3);
Dim img() As Bitmap = pdfViewer1.ExportAsImage(0, 3)

Exporting PDFs as Vector Images

Exporting PDFs as vector images can be done using the ExportAsMetafile method. The following code sample demonstrates how a PDF document can be exported as a Metafile.

Metafile img = pdfViewer1.ExportAsMetafile(0);

// Save the image

img.Save("Sample.emf", ImageFormat.Emf);
Dim img As Metafile = pdfViewer1.ExportAsMetafile(0)

' Save the image

img.Save("Sample.emf", ImageFormat.Emf)

You can also specify the page range instead of converting each page individually.

Metafile[] img = pdfViewer1.ExportAsMetafile(0, 3);
Dim img() As Metafile = pdfViewer1.ExportAsMetafile(0, 3)