Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
269 views
in Technique[技术] by (71.8m points)

javascript - Bootstrap modal - Add a object tag embedding a PDF

I'm currently trying to display a bootstrap modal in which I want to include a PDF file with the "object" html tag. Problem is that nothing seems to display.

I've created a jsFiddle (http://jsfiddle.net/mV6jJ/3/).

So you will find a basic modal (exactly same code from bootstrap for a basic modal showing after a click on a button) and in the modal-body you will find :

<object type="application/pdf" data="http://www.inkwelleditorial.com/pdfSample.pdf" width="500" height="500">this is not working as expected</object>

So when I add this code alone (so not inside a bootstrap modal) it's working as expected. It display the pdf in the browser's default pdf viewer. But when I try to implement the pdf inside of the bootstrap modal, nothing seems to appear.

If you have any idea it will really helps me, many hours searching and I've only seen solutions with tag (which I don't want to use).

Thank you and best regards

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have found that bootstrap include a css property that affect to pdf viewing in a modal window.

Change this:

.modal.in .modal-dialog {
  transform: translate(0px, 0px);
}

to:

.modal.in .modal-dialog {
  transform: none;
}

If this property is changed everything works properly.

You can see in action:

http://jsfiddle.net/mV6jJ/20/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...