|
Rank: Advanced Member Groups: Member
Joined: 5/9/2016 Posts: 84
|
There is a big problem with printing PDF in the newer builds. I have tested the two latest builds and they have the same problem. I know a build that works and that is: 18.3.46.0 What is happening is that I start a process which calls the print commands. I am able to print 1 document. Next time it hangs - and it hangs at: Again, this is not happening on 18.3.46.0. I am able to call this method as many times as I want. Here is the full code: Quote: Private Sub StartPDFPrintProcessEO(ByVal psc As PrinterSettingsClass) If TaskProcess.Task.TaskDebugging Then LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Start", TaskProcess) End If 'Create objects for printer and page settings and PrintDocument AddHandler EO.Base.Runtime.Exception, AddressOf EOException
Dim ps As New System.Drawing.Printing.PrinterSettings()
Dim pgs As New System.Drawing.Printing.PageSettings()
pgs.Margins = New System.Drawing.Printing.Margins(psc.MarginLeft, psc.MarginRight, psc.MarginTop, psc.MarginBottom)
' print range Select Case psc.PrintRange Case EnmPrintRange.AllPages ' do nothing Case EnmPrintRange.CurrentPage pgs.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.CurrentPage Case EnmPrintRange.Selection pgs.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.Selection Case EnmPrintRange.SomePages pgs.PrinterSettings.PrintRange = System.Drawing.Printing.PrintRange.Selection End Select
If TaskProcess.Task.TaskDebugging Then LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Setting printer: " & psc.SelectedPrinter, TaskProcess) End If 'Set printer name ps.PrinterName = psc.SelectedPrinter
'Set PageMargins (if required) ps.DefaultPageSettings.Margins.Left = psc.MarginLeft ps.DefaultPageSettings.Margins.Right = psc.MarginRight ps.DefaultPageSettings.Margins.Top = psc.MarginTop ps.DefaultPageSettings.Margins.Bottom = psc.MarginBottom
' copies ps.Copies = psc.NoOfCopies If TaskProcess.Task.TaskDebugging Then LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Adding printer settings", TaskProcess) End If pgs.PrinterSettings = ps
Dim pdfdoc As New PdfDocument(psc.File, psc.Password)
' add support for printing specific pages If psc.SelectedPages IsNot Nothing Then Dim selectedPages As String = GetSelectedPages(psc.SelectedPages) Dim pages() As String = selectedPages.Split(",".ToCharArray)
' create integer list of pages to print Dim intPagesToPrint As New List(Of Integer) For Each strPage As String In pages intPagesToPrint.Add(CInt(strPage)) Next
' create list of pdf pages to remove Dim lstRemovePages As New List(Of PdfPage) Dim i As Integer = 1 For Each pdfPage As PdfPage In pdfdoc.Pages If Not intPagesToPrint.Contains(i) Then lstRemovePages.Add(pdfPage) End If i += 1 Next
' remove pages from document For Each pdfPage As PdfPage In lstRemovePages pdfdoc.Pages.Remove(pdfPage) Next End If
Dim IsLandscape As Boolean = False If pdfdoc.Pages.Count > 0 Then IsLandscape = pdfdoc.Pages(0).Size.Width > pdfdoc.Pages(0).Size.Height End If
Select Case psc.PageSettings.PaperOrientation Case EnmOrientation.Landscape pgs.PrinterSettings.DefaultPageSettings.Landscape = True Case EnmOrientation.Portrait pgs.PrinterSettings.DefaultPageSettings.Landscape = False Case EnmOrientation.Auto pgs.PrinterSettings.DefaultPageSettings.Landscape = IsLandscape End Select
If TaskProcess.Task.TaskDebugging Then LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Before sending print", TaskProcess) End If mt = pdfdoc.Print(ps, pgs) If TaskProcess.Task.TaskDebugging Then LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->After sending print", TaskProcess) End If mt.WaitOne()
If TaskProcess.Task.TaskDebugging Then LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->After mt.WaitOne", TaskProcess) End If RemoveHandler EO.Base.Runtime.Exception, AddressOf EOException If TaskProcess.Task.TaskDebugging Then LogAPI.Log(False, LogClass.EventT.Debug, "StartPDFPrintProcessEO->Removing exception", TaskProcess) End If End Sub
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi,
This is just let you know that we have posted a new build (build 19.1.11) that MAY have resolved this issue for you. While trying to reproduce your issue, we have discovered another issue related to loading a second PDF file into the same PdfViewer. The new build have fixed that issue. So please try to download it from our download page and see if it resolves your issue and we can then go from there.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 5/9/2016 Posts: 84
|
Was just going to email/post back. This build indeed solves my problem too. Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
serializer wrote:Was just going to email/post back. This build indeed solves my problem too. Thanks Great. Thanks for confirming the fix!
|
|
Rank: Advanced Member Groups: Member
Joined: 5/9/2016 Posts: 84
|
It seems it is not fixed anyway. Many prints later it hangs again and application needs to be restarted.
|
|
Rank: Advanced Member Groups: Member
Joined: 5/9/2016 Posts: 84
|
Customer who is receiving the problem is printing 14 pages x 14 copies. He does this operation 2-3 times before it starts hanging again.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi, We do not know what caused this problem. Is it possible for you to leave debug monitor running when this happens again? See here for more details: https://www.essentialobjects.com/doc/common/remote_debug.aspxThanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 5/9/2016 Posts: 84
|
It is not possible to install this on end user customer computer. But I am sure you can reproduce this if you print out the same amout as described.
|
|
Rank: Advanced Member Groups: Member
Joined: 5/9/2016 Posts: 84
|
I have found one way to reproduce this. Try launching Print of a file in 3 threads at the same time. Some will get timeout and some will hang. Nothing will print. But if I print one at a time this works.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi,
This does not prove much ---- the WebView class is NOT thread safe by design, thus other classes that are based on this class is not thread safe either (except for classes that explicitly stated are multi-thread safe). So you simply can not drive it in multiple threads. Member variables will get corrupted this way and all kind of strange things will happen.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 5/9/2016 Posts: 84
|
eo_support wrote:Hi,
This does not prove much ---- the WebView class is NOT thread safe by design, thus other classes that are based on this class is not thread safe either (except for classes that explicitly stated are multi-thread safe). So you simply can not drive it in multiple threads. Member variables will get corrupted this way and all kind of strange things will happen.
Thanks! I assumed it was thread safe. I added lock on thread and now concurrent threads work - but still, after some hours of printing a lot it fails by hanging. I think you can can easily reproduce this by printing from the same process, many pages and many times. This behaviour is new since a couple of versions. When this support case was opened you had a fix you said and it made things better = it took longer before it was reproduced. While you test this on a larger scale can you point me to an older version where this worked as usual as I am getting more and more customers that cannot print anymore with my program and this component.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi,
Since we do not know the exact cause for this issue, we can not tell you for certain what is the last version that does not have this problem. However the best bet would be the last 2018 build. 2019 build uses a newer version of Chromium browser engine that brought in millions line of new code. As such we would recommend you to use the latest 2018 build (18.3.46) while we investigate this issue.
As to threading, just adding lock is not enough. You must reroute all the calls to the same thread that creates the WebView. In another word, each WebView is associated to the thread in which it is created, and all methods (except for a few) of the WebView object can only be safely called in that thread. They are not designed to be called in other threads.
Beside the thread issue, you may also want to check re-entering issue. Some of the WebView methods runs a local message pump. This message pump can allow additional user input such as clicking a button which triggers another call. This can cause problems as well.
Thanks!
|
|