如何在引导模式对话框中嵌入外部pdf?

时间:2015-10-30 09:12:20

标签: javascript jquery angularjs twitter-bootstrap pdf

我有一个外部pdf,我希望在我的页面中显示。以下工作正常:

<object frame-resize data="www.cbu.edu.zm/downloads/pdf-sample.pdf" type="application/pdf" width="200px" height="200px"></object>

问题:我想在modal窗口中显示此嵌入式pdf。但是一旦我将它移动到那里,pdf就不再正确显示了:

<a data-toggle="modal" data-target=".my-modal"></div>

            <div class="modal fade my-modal" tabindex="-1" role="dialog">
              <div class="modal-dialog" role="document">
                <div class="modal-content">

                  <div class="modal-body">
                    <object frame-resize data="www.cbu.edu.zm/downloads/pdf-sample.pdf" type="application/pdf" width="200px" height="200px"></object>
                  </div>

                </div>
              </div>
            </div>

结果:我收到以下错误:

offsetParent is not set -- cannot scroll viewer.js:150:5
scrollIntoView() viewer.js:150
PDFViewer_scrollPageIntoView() viewer.js:4880
pagechange() viewer.js:7394
PDFViewer.prototype.currentPageNumber() viewer.js:4558
pdfViewSetInitialView() viewer.js:6697
resolved()
PDF 0bf9e083c3a94f2cd2e1740080c8c88c [1.4 Acrobat Distiller 7.0.5 (Windows) / Adobe Acrobat 7.0] (PDF.js: 1.1.215)
TypeError: canvas._viewport is undefined
NotFoundError: Node was not found

我怎么能把它嵌入模态对话框?

有趣的是,当我关闭模态对话框并再次打开它时,pdf会正确呈现!

更新

解决方案:我有css标记如下:

html {
  overflow-y: scroll;
}

这是为了防止在网页超出可见内容高度时内容转移。

问题:有没有人知道如何保留这个标签,并且仅仅为模态窗口忽略它?

1 个答案:

答案 0 :(得分:0)

将模态对话框的transform属性更改为none。

.modal-dialog {
  transform: none;
}