How to show PDF using server Viewer.js?

0

On the View page, I have the following code:

<iframe style="width:800px; height:550px;" id="FileReload" src="@Url.Action("GetPDF", "Account", new { id = Model.Id })" onerror="function_documenthide();"></iframe>

Each browser has its own PDF.

The problem is the browser safari and IE. Safari does not show PDF and IE is soooo heavy.

I'm trying to show default PDF of all browsers using ViewerJS .

It works at the location where your PDF is (AppData / Document / test.pdf).

So I put this code to work with ViewerJS: (with server)

<iframe style="width:815px; height:550px;" id="FileReload" src="/ViewerJS/#../@Url.Action("GetPDF", "Account", new { id= Model.ID})"></iframe>

More does not work, give this problem below:

UPDATE

WithPDFlocationworks:

<iframestyle="float:right;" src="/ViewerJS/pdf-test.pdf" width='400' height='300' allowfullscreen webkitallowfullscreen></iframe>

In the Controller it returns with type application / pdf:

PDF = ((byte[])reader["File"]);
return new FileContentResult(PDF, "application/pdf");

Any ideas?

    
asked by anonymous 01.12.2016 / 22:06

1 answer

1

Problem solved, code follows:

Html:

<iframe src="/Scripts/ViewerJS/#/home/getpdf" width='400' height='300' allowfullscreen webkitallowfullscreen></iframe>

Controller:

public ActionResult GetPDF()
{
    using (WebClient client = new WebClient())
    {
        var t = client.DownloadData("http://www.irs.gov/pub/irs-pdf/fw4.pdf");

        return new FileContentResult(t, "application/pdf");
    }
}

See the result:

    
19.07.2018 / 16:51