We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Getting Null reference exception while displaying conteny in pdf viewer

Thread ID:





105476 Oct 29,2012 06:18 AM UTC Nov 9,2012 01:12 PM UTC ASP.NET MVC (Classic) 1
Tags: PdfViewer
Asked On October 29, 2012 06:18 AM UTC

I am using ASP.NET mvc3.In that I am using pdf viewer and I want to implement this using" memory stream".I did like
 public ActionResult Index(string docId)
           if(docId != null)
          var query =  docContext.My_general_profile_docs.Join(docContext.My_general_profile_doc_details, i => new  i.Docs_general_profile_doc_id, j => j.Docs_general_profile_doc_id,
                            (i, j) => new
                                docs_general_profile_doc = i.Docs_general_profile_doc

                byte[] buff = query.docs_general_profile_doc;
                MemoryStream mmystrm = new MemoryStream(buff);
                Stream r = mmystrm;

                PdfLoadedDocument pdfDoc = new PdfLoadedDocument(mmystrm);
                MemoryStream m = new MemoryStream();
                Stream input = m;
                ViewData["doc"] = input;
            return View();
and in the view I gave like
<div id="update" style="padding: 15px 5px 3px 5px;">          @{Html.Syncfusion().PdfViewer("PdfViewerModel").Load((Stream)ViewData["doc"]).Width(System.Web.UI.WebControls.Unit.Pixel(900)).Render();}
I am getting bytes at the ViewData["doc"] but In the view It is throwing "Null Reference Exception",can u tell me how to fix this

Meikanda Nayanar [Syncfusion]
Replied On November 9, 2012 01:12 PM UTC

Hi Charan,

Thank you for your interest in Syncfusion Products.

We created a simple PdfViewer sample to perform loading a Pdf document form stream in MVC and attached the sample in the below link.

Sample: PdfViewer_Stream.zip

Could you please try this sample and let us know whether this suits your requirement.





This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon