PDFViewer Loading New Document Does Not Display

8 posts, 1 answers
  1. michael schroeder
    michael schroeder avatar
    5 posts
    Member since:
    Mar 2010

    Posted 16 Sep 2014 Link to this post

    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
  2. George
    Admin
    George avatar
    500 posts

    Posted 19 Sep 2014 Link to this post

    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.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. michael schroeder
    michael schroeder avatar
    5 posts
    Member since:
    Mar 2010

    Posted 19 Sep 2014 in reply to George Link to this post

    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?



  5. michael schroeder
    michael schroeder avatar
    5 posts
    Member since:
    Mar 2010

    Posted 20 Sep 2014 in reply to George Link to this post

    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
  6. George
    Admin
    George avatar
    500 posts

    Posted 24 Sep 2014 Link to this post

    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.
     
  7. michael schroeder
    michael schroeder avatar
    5 posts
    Member since:
    Mar 2010

    Posted 24 Sep 2014 in reply to George Link to this post

    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.


  8. Answer
    George
    Admin
    George avatar
    500 posts

    Posted 26 Sep 2014 Link to this post

    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.
     
  9. michael schroeder
    michael schroeder avatar
    5 posts
    Member since:
    Mar 2010

    Posted 26 Sep 2014 in reply to George Link to this post

    Hi George,

    I made the changes and that did resolve the problem.

    I want to thank you for your outstanding support!

    Regards
    Michael Schroeder
Back to Top
UI for WinForms is Visual Studio 2017 Ready