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

PDFViewer slow when loading from memory

1 Answer 214 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 11 Mar 2013, 02:03 PM
Hello,

I'm loading a pdf generared on wcf side with those lines of code

if (e.Error == null)
        {
            guidPDF = e.Result.Guid;
 
            MemoryStream ms = new MemoryStream(e.Result.Bytes);
 
            pdfViewer.ReportMemoryStream = ms;
 
            DateTime dtStart = DateTime.Now;
 
         //  PdfFormatProvider provider = new PdfFormatProvider(ms, Telerik.Windows.Documents.Fixed.FormatProviders.FormatProviderSettings.ReadAllAtOnce);
        //    this.pdfViewer.Document = provider.Import();
 
            pdfViewer.DocumentSource = new Telerik.Windows.Documents.Fixed.PdfDocumentSource(ms);
            TimeSpan ts = dtStart - DateTime.Now;
        }

using the provider.Import tooks around 31Seconds for a file of around 1Mb....using the PDFSource loads fast the first page but the other pages are blank.....any suggestion?
Thanks

1 Answer, 1 is accepted

Sort by
0
Kammen
Telerik team
answered on 14 Mar 2013, 11:11 AM

Hello Paolo,

With your code you are trying to load the whole document before displaying it. There is another setting that will allow you to load your document asynchronously. This will take much less time in the beginning, as a certain page will be parsed only when requested. You just need to use FormatProviderSettings.ReadOnDemand settings instead of FormatProviderSettings.ReadAllAtOnce. 

Hope this answers your question.


Regards,
Kammen
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PDFViewer
Asked by
Michele
Top achievements
Rank 2
Answers by
Kammen
Telerik team
Share this question
or