1
votes

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

1
Steve, what is different in this question from stackoverflow.com/questions/13458150/…? 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
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 <object /> 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
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 stackoverflow.com/questions/4853898/… but not sure if it might work for streaming. - OnaBai

1 Answers

1
votes

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