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