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

PDF Viewer loads PDF from Memory Stream very slow

7 Answers 378 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 22 Dec 2015, 06:42 PM

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);
   }
}

7 Answers, 1 is accepted

Sort by
0
Aylin
Telerik team
answered on 24 Dec 2015, 10:49 AM
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
0
Keith
Top achievements
Rank 1
answered on 24 Dec 2015, 03:09 PM

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

0
Accepted
Aylin
Telerik team
answered on 25 Dec 2015, 11:39 AM
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
0
Keith
Top achievements
Rank 1
answered on 28 Dec 2015, 04:26 PM
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
0
Tanya
Telerik team
answered on 29 Dec 2015, 08:29 AM
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
0
Flemming
Top achievements
Rank 1
Veteran
answered on 04 Sep 2018, 05:18 PM

Thank you! Now I can load a large document (only 17 MB) of 200 pages full of pictures, without any problems. It was the specific height that I needed. Consider putting that in the common problems sections of the control :)

https://docs.telerik.com/devtools/wpf/controls/radpdfviewer/troubleshooting-common-problems

0
Tanya
Telerik team
answered on 07 Sep 2018, 11:29 AM
Hi Flemming,

I am happy to hear that everything is working as expected.

Thank you for the suggestion - I updated the topic and the change will be live with our next upload. I added Telerik points to your account as a small token of gratitude for bringing this to our attention.

Regards,
Tanya
Progress Telerik
Get quickly and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
PDFViewer
Asked by
Keith
Top achievements
Rank 1
Answers by
Aylin
Telerik team
Keith
Top achievements
Rank 1
Tanya
Telerik team
Flemming
Top achievements
Rank 1
Veteran
Share this question
or