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
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

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
Please find my answer in the support thread you have started on the topic.
Regards,
Aylin
Telerik

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
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

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
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