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

[Solved] Display PDF in Window

0 Answers 62 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
kalpesh
Top achievements
Rank 1
kalpesh asked on 14 Dec 2011, 04:07 AM
Hi Guys,

I have problem with Window in MVC in my web application. I was trying to get PDF from server side and return to view. 

server side code :
byte[] pdf = null;
                FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                BinaryReader br = new BinaryReader(fs);
                long numBytes = new FileInfo(filePath).Length;
                pdf = br.ReadBytes((int)numBytes);
                return File(pdf, "application/pdf");

then after i want to display PDF in iframe which is available in window. but it could display PDF. it display PDF few seconds, then it display like image which i attached.

this is my .cshtml code
@{Html.Telerik().Window()
       .Name("Window")
       .LoadContentFrom("GetPDF?InvoiceID=1683714)
       .Title("View Invoice")
       .Content(@<text>
                @using (Html.BeginForm("popupform", "window", FormMethod.Post, new { id = "InvoiceID" }))
                {
                    if (Session["InvoiceID"] != null)
                    {
                        <iframe src="GetPDF?InvoiceID=1683714" width="100%" height="100%"/>
                    }
                }
                </text>)
       .Width(400)
       .Height(500)
       .Draggable(true)
       .Modal(true)
       .Visible(false)       
       .Render();
       }
Tags
Window
Asked by
kalpesh
Top achievements
Rank 1
Share this question
or