We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to batch print PDF in WPF PDFViewer control?

Platform: WPF |
Control: PdfViewer |
Published Date: April 12, 2018 |
Last Revised Date: July 28, 2021

You can batch print the multiple PDF files using WPF PdfViewer by loading and printing the PDFs one by one in a loop. Add the PDFs present in a directory to a ListView and batch print the multiple PDFs that are selected from the ListView. Refer to the following code sample.

C#

char[] charSplitter = new char[] { '/' };
//Get the PDF files from the directory
files = Directory.GetFiles("../../Data/", "*.pdf");
foreach (string file in files)
{
    //Splitting the file name from the file path
    string[] fileName = file.Split(charSplitter);
    //Adding the file into the list view
    list.Items.Add(fileName[3]);
}
 
if (list.SelectedItems.Count > 0)
{
    for (int i = 0; i < list.SelectedItems.Count; i++)
    {
        string fileName = list.SelectedItems[i].ToString();
        for (int j = 0; j < files.Length; j++)
        {
            if (files[j].Contains(fileName))
            {
                //Initialize the PdfLoadedDocument
                ldoc = new PdfLoadedDocument(files[j]);
                //Load the PdfDocument into PdfViewerControl/PdfDocumentView
                pdfViewer.Load(ldoc);
                //Silent print the PDF document
                pdfViewer.Print();
                //Unload the PdfViewerControl after printing
                pdfViewer.Unload();
                //Close the PdfLoadedDocument
                ldoc.Close(true);
             }
         }
     }
}

View sample in GitHub.

UG link: https://help.syncfusion.com/wpf/pdf-viewer/printing-pdf-files#silent-printing

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile