0

I am working to show in my view a PDF that comes as a URL. To do that I am using object tag. But my problem is that the PDF does not show.

This is my code, to start I hardcoded to test the behaviour in my view:

form id="EditRecurso" method="post" action="#" enctype="multipart/form-data"> @Html.AntiForgeryToken() @Html.ValidationSummary(true, "Please fix the following errors.") <div class="container"> <div class="form-group"> @Html.LabelFor(c => c.Titulo) @Html.TextBoxFor(c => c.Titulo, new { @class = "form-control" }) @Html.ValidationMessageFor(m => m.Titulo) </div> <div class="form-group"> @Html.LabelFor(c => c.Descripcion) @Html.TextAreaFor(c => c.Descripcion, new { @class = "form-control" }) @Html.ValidationMessageFor(m => m.Descripcion) </div> //show here the pdf --> <object data="https://www.salisbury.edu/helpdesk/doc/Computer/Operating_System_Bios_Boot/OS_Windows7ProductGuide.pdf" type="application/pdf" width="600" height="300"></object> <div class="form-group"> @Html.LabelFor(m => m.Url) @Html.TextBoxFor(m => m.Url, new { type = "file", name = "miRecurso" }) @Html.ValidationMessageFor(m => m.Url) </div> <button id="submiter" type="submit" class="btn btn-primary">Listo!</button> </div> 

And the result in my MVC view is this:

PDF not showing As you can see it never shows the PDF. But the object tag is there.

On the other hand, when I use plain HTML with the same object tag to link a PDF, this is the result:

PDF displayed in html document

<html> <head> <title></title> </head> <body> <object data="https://www.salisbury.edu/helpdesk/doc/Computer/Operating_System_Bios_Boot/OS_Windows7ProductGuide.pdf" type="application/pdf" width="600" height="300"></object> </body> </html> 

Any Idea what I am doing wrong and how I can fix it?

2
  • I just copied and pasted your code and it worked for me in chrome. Do you have some CSS which is placing the object out of visibility ? Commented Oct 12, 2017 at 21:19
  • Your code works in Firefox 54 & Chrome 60 - do you missing some important objects which not included in this question? Commented Oct 13, 2017 at 0:37

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.