1

I am trying to display a PDF stream into a KendoUI window.

When the results are returned to the KendoUI window, the raw data of the PDF is displayed. I started Fiddler to see if the content-type is coming through correctly. Fiddler does show the proper content-type.

I have tried a number of different interactions. Each attempt yields the same result listed below.

Here is snippet from the controller:

    public FileStreamResult DownloadV3()
    {
        //Create and populate a memorystream with the contents of the database table
        MemoryStream mstream = GetPDFData();

        HttpContext.Response.AddHeader("content-disposition", "attachment; filename=form.pdf");

        return new FileStreamResult(mstream, "application/pdf");
    }

Here is a snippet of what is displayed in KendoUI window:

%PDF-1.5 5 0 obj <>>> endobj 6 0 obj <>stream

Here is a snippet of the javascript:

<script type="text/javascript">
$(document).ready(function () {
    $("#view1").bind("click", winOpen);
});
function winOpen() {
    var id = '6CA88CA9-4F33-E211-84AC-B4A17689C6D9';
    var kendoWindow = $("#kjWindow").kendoWindow({
        title: "View File",
        width: "750px",
        height: "480px",
        content: "/home/DownloadV3/" + id,
        modal: true,
        actions: ["Close", "Refresh", "Maximize"]
    });
}

Any thoughts on what I am missing/

Thanks.

Steve

tereško
  • 58,060
  • 25
  • 98
  • 150
Steve
  • 927
  • 3
  • 10
  • 23
  • Steve, what is different in this question from http://stackoverflow.com/questions/13458150/how-to-populate-a-kendui-window? In that case you also asked about populating it with a PDF. I redirect you to the solution that I proposed since I have used it and it worked. – OnaBai Nov 21 '12 at 18:12
  • Emiliano, in that post, I was trying to figure out how to load content into the KendoUI window other than the server side control. I discovered that content: property allowed me to send to reference my controller and send back an tag. My ultimate goal is to be able to send a stream to the KendoUI window (as shown above). I am new to the KendoUI world so any thoughts would be appreciated. – Steve Nov 21 '12 at 18:55
  • I don't know how to solve your problem but two possible clues: 1. KendoUI documentation says that container is only for HTML, I didn't take a look into the code (it's open-source) but did some quick tests with jpeg, gifs, pdf... and failed, so seems that it's actually true. 2. most webs displaying PDF documents either use embed/object or use special libraries, take a look into http://stackoverflow.com/questions/4853898/display-pdf-within-web-browser but not sure if it might work for streaming. – OnaBai Nov 21 '12 at 21:30

1 Answers1

1

I guess the kendo window tries to get the URL content through an Ajax request, you cant retrieve non html content through ajax, try putting an iframe inside the window and point it to the URL

ryudice
  • 36,476
  • 32
  • 115
  • 163
  • I added the property for iframe=true. The page does display the pdf now but not inside of the window. I get the open window from the browser. Unfortunately, I need to get it displayed in the kendoUI window. – Steve Nov 21 '12 at 16:32
  • I think there is an option to make the kendo window show as an iframe, is that what you did? – ryudice Nov 21 '12 at 17:38
  • yes. looking at the original message, I added 'iframe: true' (minus quotes) after modal: true. – Steve Nov 21 '12 at 18:45