PDFViewer slow when loading from memory

2 posts, 0 answers
  1. Paolo
    Paolo avatar
    423 posts
    Member since:
    Jun 2009

    Posted 11 Mar 2013 Link to this post

    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
  2. Kammen
    Admin
    Kammen avatar
    312 posts

    Posted 14 Mar 2013 Link to this post

    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.

  3. DevCraft banner
Back to Top