Printing PDF

Printing can be done using the Print method or by using the Print command.

The following code shows how to perform the print operation using Print method. 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.

private void Page_Loaded(object sender, RoutedEventArgs e)
{
    PdfLoadedDocument loadedDocument = new PdfLoadedDocument(buffer);
    pdfViewer.LoadDocument(loadedDocument);
}

private void Button_Click(object sender, RoutedEventArgs e)
{
    //Prints the document loaded in the PDF viewer
    pdfViewer.Print();
}
Private Sub Page_Loaded(sender As Object, e As RoutedEventArgs)
    Dim loadedDocument As New PdfLoadedDocument(buffer)
    pdfViewer.LoadDocument(loadedDocument)
End Sub

Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
    'Prints the document loaded in the PDF viewer
    pdfViewer.Print()
End Sub

The following code shows how to bind the PrintCommand to a Button

<Grid>
        <syncfusion:SfPdfViewerControl Name="pdfViewer"/> 
        <Button Command="{Binding PrintCommand}" />
</Grid>

NOTE

The SfPdfViewer control for UWP does not support silent printing and so this method can be used only when the PDF document is displayed in the PDF viewer.