Export PDF using ExportProvider
In This Topic
PdfDocumentSource allows you to enumerate the supported export formats for a document using the SupportedExportProviders property. The property returns a collection of ExportProvider classes that contain information about the supported formats, and can be used to create the corresponding export filter by using the NewExporter method of ExportProvider class.
Different document types support different sets of export formats, therefore enumerating and creating the export filters via SupportedExportProviders yields the correct results.
To export PDF using supported exporters
- Drag and drop Button and ComboBox controls from the Toolbox on the design view.
- Switch to code view and add the following namespaces in the code view.
- Add a PDF file to the project. In our case, we have used PDF file named DefaultDocument.pdf from the product sample.
- Initialize the instances of C1PDFDocumentSource and create an instance of StorageFile class using the following code:
- Load the PDF file into the object of C1PdfDocumentSource using the LoadFromFileAsync method.
- Add the following code below InitializeComponent() method to get the list of supported exporters using SupportedExportProviders property.
- Add the following code to the button's click event to export the PDF file using ExportAsync method.
See Also