PDF Viewer loads PDF from Memory Stream very slow

6 posts, 1 answers
  1. Keith
    Keith avatar
    3 posts
    Member since:
    Feb 2014

    Posted 22 Dec 2015 Link to this post

    Hello,

      I am using the PDFViewer control and my intent is to show a PDF (prior to writing to disk), the issue I am having is that once the PDF attempts to load into the PDF Viewer it is incredibly slow.  The PDF is larger in size (roughly 167+ pages) but that is not uncommon for the average pdf we are generating.  My question is, is there anyway to optimize loading information into this control to make PDF's not take an upward of 10-15 minutes to load?

    Code Example:

    private void LoadPdfToView()
    {
      try
      {
         //Create a memory stream we will use to hold our PDF
         MemoryStream DocumentStream = new MemoryStream();
         //A 3rd party control that creates the PDF document (this save feature can save to memory stream or to disk)
         TheDoc.Save(DocumentStream);
         //Create the Fixed document based on the PDF document in memory
         RadFixedDocument document = new PdfFormatProvider DocumentStream, FormatProviderSettings.ReadOnDemand ).Import();
         //Load the pdf document into our control
         pdfViewer.Document = document;
       }
       catch (Exception ex)
       {
         MessageBox.Show("Error Loading PDF to view: " + ex.Message);
       }
    }

  2. Aylin
    Admin
    Aylin avatar
    75 posts

    Posted 24 Dec 2015 Link to this post

    Hello Keith,

    We are currently working on some memory and performance optimizations for RadPdfViewer when rendering big images. Here is the related public feedback item: Improve the memory and the performance of RadPdfViewer when rendering big images. These fixes might improve the loading performance at your side, however, in order to specify which exactly is the root cause, it would be best if we could reproduce the issue on our side. That's why I would ask you to send us a sample document and the exact steps to reproduce.

    Also, could you check if the issue is applicable only for a specific document or it happens for each document you try to display in PdfViewer?

    Regards,
    Aylin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Keith
    Keith avatar
    3 posts
    Member since:
    Feb 2014

    Posted 24 Dec 2015 in reply to Aylin Link to this post

    Aylin,

      Thank you for replying to my post.  To answer your question I have tried a few different PDF documents (some I have created some are just from user manuals) and my findings are that larger files, pages of 50+, is when you start to notice a substantial increase in PDF loading times.  I will be sending two test PDF documents that I am generating using that 3rd party tool I mentioned in my original post to you on the support ticket.  The one is only 2 pages and loads almost instantly, the other is 124 pages and you can see that it takes longer than 5 minutes on average to load.  However when opening the PDF normally by double clicking on it outside of using the RadPdfViewer, the PDF shows almost as fast as the 2 page document one.  Also I clicked on that link provided in your answer and it seems that the thread is still unanswered. 

    Again, thank you for your reply and I look forward to hearing back from you

  5. Answer
    Aylin
    Admin
    Aylin avatar
    75 posts

    Posted 25 Dec 2015 Link to this post

    Hello Keith,

    Please find my answer in the support thread you have started on the topic.

    Regards,
    Aylin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Keith
    Keith avatar
    3 posts
    Member since:
    Feb 2014

    Posted 28 Dec 2015 in reply to Aylin Link to this post

    Aylin,

      Thank you for the response. Upon comparing the projects I found that the root cause of the slow loading speeds was due to the fact that I had my RadPdfViewer inside of a Scroll Viewer (I did not realize that the Rad control had a built in scroll viewer).  I assume that there was something in expanding/drawing of the scroll viewer that was causing the increase in load time.  Thank you for working with me to a solution and I hope you and your team keep up the great work!

    Thanks: Keith
  7. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 29 Dec 2015 Link to this post

    Hello Keith,

    The ScrollViewer measures its size with Infinity and that causes loading the whole document. Actually, RadPdfViewer visualizes the documents in parts - while the user scrolls in it - and this optimization is lost when the control is placed in a container without a specified size. As the document pages themselves should be measured and visualized all at once, loading a bigger document takes much time.

    Regards,
    Tanya
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready