This is a migrated thread and some comments may be shown as answers.

PDFViewer Loading New Document Does Not Display

7 Answers 229 Views
PdfViewer and PdfViewerNavigator
This is a migrated thread and some comments may be shown as answers.
michael schroeder
Top achievements
Rank 1
michael schroeder asked on 16 Sep 2014, 04:37 PM
I am working on a Windows Forms Application that automatically loads a PDF file and then scrolls through the pages.  I am using 2 timers, one to scroll the page, and the other to check for a new version of the PDF file.  When I find a new version of the PDF file, I unload the current file and then load the new file.  All of this appears to work.  The problem is that the document does not appear unless I click on the form.  I can see the scroll bar moving.

Here is the subroutine that loads the document:

    Private Sub LoadPDFFile()

        If File.Exists(My.Settings.PDFFileName) Then
            mCurrrentFileInfo = My.Computer.FileSystem.GetFileInfo(My.Settings.PDFFileName)

            If PdfViewer.IsLoaded Then
                PdfViewer.UnloadDocument()
            End If

            PdfViewer.LoadDocument(My.Settings.PDFFileName)
            PdfViewer.PdfViewerElement.GoToPage(1)
        End If

    End Sub


OS: Windows 8
.Net 4.5
PDFViewer Version: 2014.2.715.40

7 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 19 Sep 2014, 12:42 PM
Hello Michael,

Thank you for writing.

I tried to load a pdf file using a timer but was not able to reproduce the described behavior locally. I guess that there is something specific to your code and/or pdf file. Can you provide me with a sample project which reproduces the problematic behavior so I can properly investigate it locally.

Looking forward to your reply.

Regards,
George
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
michael schroeder
Top achievements
Rank 1
answered on 19 Sep 2014, 08:37 PM
I attempted to duplicate the problem on my development machine, but was not able to.  So I took the new version of the code up to my client's server.  When I run the code on their server the page does not scroll.  The vertical scroll bar is moving, but the screen is not updating.  In the attached zip file I have included the code along with a short video that shows the problem on my client's server.  in the video notice the scroll bar moving and the document not.  At around the 15 second mark I click in the body of the document.  When I do this the page updates.  At around the 28 second mark I resize the window out of view of the recording, and the document updates.

The video file name is DemoPDFViewer.mp4.

It looks like I can't attach a zip file.  Can I email the file to you?



0
michael schroeder
Top achievements
Rank 1
answered on 20 Sep 2014, 06:52 PM
Hi George,

Here is a link to the zip file https://files.secureserver.net/0stcqHfGPAJ7hk.  The ZIP file contains the VS project and the video that shows the problem.

If there are any questions, please let me know.

Regards
Michael Schroeder
0
George
Telerik team
answered on 24 Sep 2014, 01:52 PM
Hi Michael,

Thank you for writing.

I tried your project, however on my end it seems to be working fine. I tried with the file attached below. Can you check it on your end? Possibly you can give me some more information about the steps I need to take to reproduce the problematic behavior? Alternatively, you can try to invoke the UpdateLayout method after you have scrolled:
PdfViewer.PdfViewerElement.UpdateLayout()

Looking forward to your reply.

Regards,
George
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
michael schroeder
Top achievements
Rank 1
answered on 24 Sep 2014, 04:30 PM
Hi George,

I added the call to PdfViewer.PdfViewerElement.UpdateLayout in the subroutine that scrolls the page.  I also tried using the XML document that you provided.  This works on my development machine, but does not work on my clients machine.  I can see the scroll bar moving.  If I click on the body of the pdf file or resize the window, the document updates the display.

Here is the code:

Private Sub ScrollPageTimerEvent(source As Object, e As ElapsedEventArgs)

        Dim iCurrentPage As Integer
        Dim iPreviousPage As Integer

        Try
            oScrollPageTimer.Stop()

            iPreviousPage = PdfViewer.PdfViewerElement.CurrentPage.PageNo

            PdfViewer.PdfViewerElement.PageDown()

            iCurrentPage = PdfViewer.PdfViewerElement.CurrentPage.PageNo

            If iPreviousPage <> 0 And iCurrentPage = iPreviousPage Then
                PdfViewer.PdfViewerElement.GoToPage(1)
            End If

            PdfViewer.PdfViewerElement.UpdateLayout 

            oScrollPageTimer.Start()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

The client is running Windows Server 2008 R2 Standard with SP1.


0
Accepted
George
Telerik team
answered on 26 Sep 2014, 11:35 AM
Hello Michael,

Thank you for your reply.

I was able to identify the problem in your project. It seems that you are using timers from the System.Timers namespace which is not compatible with WinForms since they run in a different thread, that is why they are not suitable for updating the UI. Please, use Timer from the System.Windows.Forms namespace, this way you should not observe such behavior.

I hope this helps.

Regards,
George
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
michael schroeder
Top achievements
Rank 1
answered on 26 Sep 2014, 05:47 PM
Hi George,

I made the changes and that did resolve the problem.

I want to thank you for your outstanding support!

Regards
Michael Schroeder
Tags
PdfViewer and PdfViewerNavigator
Asked by
michael schroeder
Top achievements
Rank 1
Answers by
George
Telerik team
michael schroeder
Top achievements
Rank 1
Share this question
or