JavaScript How to embed an external pdf in a bootstrap modal dialog?

I have an external pdf that I'd like to show embedded in my page. The following works fine:

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

Problem: I want to show this embedded pdf in a modal window. But as soon as I move it there, the pdf is not displayed correctly anymore:

<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>

Result: I'm getting the following error:

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

How can I though embed this into a modal dialog?

Interestingly, when I close the modal dialog and open it again, the pdf is rendered correctly!

Update:

Solution: I had css tag as follows:

html {
  overflow-y: scroll;
}

This is to prevent content shifting when the webpage exceeds the visible content height.

Question: does anybody know how I can keep this tag, and ignore it just for the modal window?

Answer:1

I have a solution but its taking too much time. Here is my solution. //------------ Image url to base64 -------------// function convertImgToBase64(url, callback, outputFormat){ var img =...

I have a solution but its taking too much time. Here is my solution. //------------ Image url to base64 -------------// function convertImgToBase64(url, callback, outputFormat){ var img =...

  1. blob data from base64
  2. dataurl to blob
  3. blob data to image converter online
  4. blob data to string
  5. blob data in oracle
  6. blob data to string online
  7. blob data in sql server
  8. blob data to image
  9. blob data in json
  10. blob data in mysql
  11. blob data to base64 javascript
  12. blob data to string java
  13. blob data in sql
  14. blob data to pdf
  15. blob data in aws
  16. blob data to image online
  17. blob data in mongodb
  18. blob data in javascript
  19. blob data in java
  20. blob data in postgres

I was trying to get the background color of an element using javascript: URL: https://mathemagiker.de/ Javascript: document.getElementById('angebot').style.backgroundColor Result: Nothing However ...

I was trying to get the background color of an element using javascript: URL: https://mathemagiker.de/ Javascript: document.getElementById('angebot').style.backgroundColor Result: Nothing However ...

How I can use selectize.js with remote source? I have followed this example: $('#select-repo').selectize({ valueField: 'url', labelField: 'name', searchField: 'name', create: false, ...

How I can use selectize.js with remote source? I have followed this example: $('#select-repo').selectize({ valueField: 'url', labelField: 'name', searchField: 'name', create: false, ...

  1. selectize remote data
  2. selectize remote source
  3. selectize remote data loading
  4. selectize remote
  5. selectize remote source example
  6. selectize remote data example
  7. selectize remote json

i'm trying to inline edit an input this way, i wrote a clickOutside directive and it works fine but in my example when i click to edit editMode becomes true and immediately input is shown and ...

i'm trying to inline edit an input this way, i wrote a clickOutside directive and it works fine but in my example when i click to edit editMode becomes true and immediately input is shown and ...

  1. input inline edit
  2. lightning input inline edit
  3. inline edit input angular