Getting Null reference exception while displaying conteny in pdf viewer

hi,
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
                               }).FirstOrDefault();

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

                PdfLoadedDocument pdfDoc = new PdfLoadedDocument(mmystrm);
                MemoryStream m = new MemoryStream();
                pdfDoc.Save(m);
                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();}
 </div>
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

1 Reply

MN Meikanda Nayanar Syncfusion Team 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.

Regards,

Meikandan

 


Loader.
Up arrow icon