Xamarin.Forms | ComponentOne
Controls / FlexViewer / Features / Export Document
In This Topic
    Export Document
    In This Topic

    FlexViewer allows you to export a PDF document and save it to a file, stream or as an image(s). You can export the PDF documents using Export command button from the hamburger menu. Alternatively, you can export a document and save it to a file, stream or as an image programmatically using Save method of the FlexViewer class. Furthermore, you can use various methods provided by the FlexViewer class to save a PDF document as an image. These methods are listed in the following table:

    Methods Description
    SaveAsBmp Saves the document pages as images in BMP format, i.e., one image for each page.
    SaveAsGif Saves the document pages as images in GIF format, i.e., one image for each page.
    SaveAsJpeg Saves the document pages as images in JPEG format, i.e., one image for each page.
    SaveAsPng Saves the document pages as images in PNG format, i.e., one image for each page.
    SaveAsTiff Saves the document pages as images in TIFF format, i.e., one image for each frame.

    The following code illustrates how to export PDF pages to images. This example uses the sample code created in Quick Start section.

    C#
    Copy Code
    //Output range object which defines which pages of the document should be saved
    OutputRange pageRange = new OutputRange(1, 2);
    
    //Specify the options that should be used while saving the document's pages to image 
    SaveAsImageOptions saveOptions = new SaveAsImageOptions()
    {
        BackColor = Color.LightCyan,
        Resolution = 100
    };
    
    //Save image as png to a local system folder
    flexViewer.SaveAsPng(Path.Combine(Environment.GetFolderPath(
        Environment.SpecialFolder.LocalApplicationData), "New{0}.png"), pageRange, saveOptions);