KenTay7
KenTay7

Reputation: 171

PDF object not displaying second time in modal

I want to display a pdf in a Bootstrap modal, so in the .modal-body I added :

<object width="1000" height="500" data="path/to/pdf" type="application/pdf">
      <embed src="path/to/pdf" type="application/pdf" />
</object>

My problem is that the first time I open the modal, the pdf appears well but the second time and after it shows a grey screen as followed : enter image description here

When I press F11 or F12, the PDF come back normally, but again if I close and open it shows grey. I precise that the modal is created through Jquery just in case it can cause any trouble.

Upvotes: 2

Views: 1146

Answers (2)

Karthik
Karthik

Reputation: 65

Possible solution in this case is to re render the element (either embed or IFrame). Don't remove and create it every time instead try to update the src, title or any attributes as you want. This would help to display the PDF without any issues.

Upvotes: 0

Simone
Simone

Reputation: 11

You can use this solution: JavaScript: Changing src-attribute of a embed-tag

The embed tag must be removed an recreated through jquery, otherwise it remains in the cache.

Upvotes: 1

Related Questions