Display PDF downloaded from Azure

0 Answers 149 Views
PDFViewer
Eddie
Top achievements
Rank 1
Eddie asked on 23 Dec 2022, 05:46 PM

I am trying to use the PDFViewer to display a PDF downloaded from an Azure Blob.

In my view I have:


// Create a viewer if you do not have one already.
        var pdfViewer = $("#pdfViewer").data("kendoPDFViewer");
        if (!pdfViewer) {
            pdfViewer = $("#pdfViewer").kendoPDFViewer({
                pdfjsProcessing: {
                    file: ""
                },
                width: "100%",
                height: 500
            }).data("kendoPDFViewer");
        };

        // Build the desired URL to point to your handler that will return the PDF.
        var pdfHandlerUrl = "/Home/getBlob/" + selectedRows.BlobID;

        // Make the PDFViewer load the designated file.
        pdfViewer.fromFile(pdfHandlerUrl);

An in my controller (getBlob) I have the following:


var stream = new MemoryStream();
await file.DownloadToAsync(stream);
  stream.Position = 0;
                   
 return new FileStreamResult(stream, "application/pdf");

But in the view - I get a pop-up error message that says: PDF file fails to process.

 

Any suggestions?

 

 

 

 

 

Georgi
Telerik team
commented on 28 Dec 2022, 06:36 AM

Hi Eddie,

Could you please verify that the file is correct and it downloads successfully? You could do that by directly requesting the pdfHandlerUrl from the browser

No answers yet. Maybe you can help?

Tags
PDFViewer
Asked by
Eddie
Top achievements
Rank 1
Share this question
or