Looking for the ability to specify duplex and the number of copies when silently printing files

I am converting a web service to leverage Syncfusion to silently print PDF files. The existing functionality supports: duplex, scaling, and number of copies. 

I am able to set the PrinterSetting.PageSize to accommodate scaling.

For copies I am simply looping thru and printing one at a time.

            pdfViewerControl.Load(inFileName)
            While count < inCopies
                pdfViewerControl.Print(inPrinter)
                count += 1
            End While

I have not found any options to define whether the document is printed Simplex, DuplexFlipLognEdge, or DuplexPrintShortEdge.

Has anyone else run into this?

7 Replies 1 reply marked as answer

DB David Brooks May 10, 2021 07:54 PM UTC

After posting I found another class PdfDocumentView. It appears to have the same limitations but are there pros and cons on using either class to silently print?


DD Divya Dhayalan Syncfusion Team May 11, 2021 06:33 PM UTC

Hi David, 
 
Thank you for contacting Syncfusion support. 
 
We do not have support to set Simplex, DuplexFlipLognEdge, or DuplexPrintShortEdge with PdfViewer PrinterSettings
 
The PdfDocumentView have less UI component compared to PdfViewerControl. There is no difference between printing with PdfViewerControl and PdfDocumentView.  
 
Regards, 
Divya


PG Pon Geetha A J Syncfusion Team May 12, 2021 05:30 AM UTC

To: Syncfusion Support <[email protected]>
Subject: RE: [EXT] Syncfusion support community forum 165345, Looking for the ability to specify duplex and the number of copies when silently printing files , has been updated. 
 
Do you have any other suggestions on how we could use Syncfusion to silently print a PDF with these parameters: file name, printer name, plex mode, copies, and scale mode? 
 
David Brooks 




DD Divya Dhayalan Syncfusion Team May 12, 2021 06:34 PM UTC

Hi David, 
 
We are currently checking on the possibilities to achieve your requirement we will update further details on 17th May 2021. 
 
Regards, 
Divya 



DD Divya Dhayalan Syncfusion Team May 17, 2021 03:49 PM UTC

 
Thank you for your patience. 
 
We have analyzed your requirement and created a Windows Forms application which hosts a WPF PdfViewerControl (Since we do not have support to specify Duplex mode and copies in WinForms PdfViewer ). With WPF PdfViewerControl we can achieve your requirement “To silently print a PDF with these parameters file name, printer name, plex mode, copies, and scale mode” by using PrinterSettings Property and Print(printer name) method.  
 
Please find the KB link to host PDF viewer WPF in windows forms application from below,  
 
Please find the below UG link to know more about printing pages in WPF PdfViewerControl. 
 
Please download the sample which we have created for your reference from the below link, 
 
In this sample, the file name, duplex mode, scale mode and copies properties are set to the printer using the PrinterSettings (DocumentName, Duplex, PageSize, Copies) Properties. And, the printer’s name ("Microsoft print to PDF") is passed to the PdfViewerControl Print method to specify the printer.  
 
Please find the below code snippet for the same. 
 
private void SilentPrint_Click(object sender, EventArgs e) 
        { 
            //To set File name 
            pdfViewer.pdfViewerControl.PrinterSettings.DocumentName = "PdfViewer_Http_Succinctly"; 
             
            // To set Duplex mode as "Simplex" 
            pdfViewer.pdfViewerControl.PrinterSettings.Duplex = System.Drawing.Printing.Duplex.Simplex; 
            // To mention number of copies 
            pdfViewer.pdfViewerControl.PrinterSettings.Copies = 2; 
            //To mention the scale mode 
            pdfViewer.pdfViewerControl.PrinterSettings.PageSize = Syncfusion.Windows.PdfViewer.PdfViewerPrintSize.Fit; 
 
            //Passing the Printer Name as a parameter 
            pdfViewer.pdfViewerControl.Print("Microsoft print to PDF"); 
        } 
 
Note: the duplex mode Enum ‘Horizontal’ represents the ‘DuplexPrintShortEdge’ and the duplex mode Enum ‘Vertical’ represents the ‘DuplexFlipLognEdge’ mode. Please find the following link for the Enum value specification: https://docs.microsoft.com/en-us/dotnet/api/system.drawing.printing.duplex?view=net-5.0  
 
Please let us know if the above details are useful to achieve your requirement. 
 
Regards, 
Divya 


Marked as answer

PG Pon Geetha A J Syncfusion Team June 9, 2021 04:18 AM UTC

To: Syncfusion Support <[email protected]>
Subject: RE: [EXT] Syncfusion support community forum 165345, Looking for the ability to specify duplex and the number of copies when silently printing files , has been updated.
 

I finally got some time to look at this again and I at least got the web service to build. The web service is using the WPF PdfViewerControl. I had to start a single thread but when I try to load the file it doesn’t find the file, or at least the DocumentInfo.FileName is empty. The PdfViewControl is not hosted by a Windows Form application. 
 
Do we have to create a Windows form just to make this work?  
 
Is there some initialization I can do to get the file to load?  
 
Instead of emailing back and forth do you think a Teams/Zoom meeting would help? 
 
Here are some snippets from the code I have now 
 
References 
 
 
Imports Syncfusion.Pdf 
Imports Syncfusion.Windows.PdfViewer 
 
 
    Public Sub SingleThreadSynfusionPrintPDF(ByVal inFileName As String, 
                            ByVal inPrinter As String, 
                            ByVal inMode As PlexMode, 
                            ByVal inCopies As Int16, 
                            ByVal inScaleMode As ScaleMode) 
        Dim Thread = New Thread(New ThreadStart(Sub() SynfusionPrintPDF(inFileName, inPrinter, inMode, inCopies, inScaleMode))) 
        Thread.SetApartmentState(ApartmentState.STA) 
        Thread.Start() 
    End Sub 
    Private Sub SynfusionPrintPDF(ByVal inFileName As String, 
                            ByVal inPrinter As String, 
                            ByVal inMode As PlexMode, 
                            ByVal inCopies As Int16, 
                            ByVal inScaleMode As ScaleMode) 
 
        Dim pdfViewerControl As PdfViewerControl = New PdfViewerControl() 
 
        Try 
            pdfViewerControl.Load(inFileName) 
            If pdfViewerControl.DocumentInfo.FileName = "" Then 
                Throw New System.Exception("File not found: " & inFileName) 
            End If 
            Select Case inMode 
                Case PlexMode.Duplex 
                    pdfViewerControl.PrinterSettings.Duplex = DuplexMode.DuplexFlipLongEdge 
               Case PlexMode.DuplexHorizontal 
                    pdfViewerControl.PrinterSettings.Duplex = DuplexMode.DuplexFlipShortEdge 
                Case Else 
                    pdfViewerControl.PrinterSettings.Duplex = DuplexMode.Simplex 
            End Select 
            Select Case inScaleMode 
                Case ScaleMode.FitToPrintableArea 
                    pdfViewerControl.PrinterSettings.PageSize = PdfViewerPrintSize.Fit 
                Case ScaleMode.ShrinkToPrintableArea 
                    pdfViewerControl.PrinterSettings.PageSize = PdfViewerPrintSize.Fit 
                Case ScaleMode.Both 
                    pdfViewerControl.PrinterSettings.PageSize = PdfViewerPrintSize.Fit 
                Case ScaleMode.None 
                    'Do nothing  
            End Select 
            pdfViewerControl.PrinterSettings.ShowPrintStatusDialog = False 
            pdfViewerControl.PrinterSettings.Copies = inCopies 
            pdfViewerControl.Print(inPrinter) 
        Catch ex As System.Exception 
        Finally 
            pdfViewerControl = Nothing 
        End Try 
 
    End Sub 
 
 
 
David Brooks 



DD Divya Dhayalan Syncfusion Team June 9, 2021 03:00 PM UTC

Hi David, 
 
A support incident to track the status of this query has been created under your account for a better follow up on the reported issue. Please log on to our support website to check for further updates.      
  
 
Kindly let us know if you need further assistance.  
       
Regards, 
Divya 


Loader.
Up arrow icon