Open a pdf in a iframe with close button on the page

Open a pdf in a iframe with close button on the page

GargiucnGargiucn Posts: 113Questions: 32Answers: 0

Good day,
I am using iframe with datatables to prevent the full path of programmes and especially pdf documents from being displayed.
I would like to be able to open a pdf on a page where I can also insert a close button.
Any advice is appreciated...
Giuseppe

Answers

  • allanallan Posts: 64,892Questions: 1Answers: 10,747 Site admin

    Hi Giuseppe,

    It should be perfectly possible, but you'd to modify the library code a little bit. Here specifically - instead of using .open() or .download() get the Blob and draw that into an iframe on your new page with the close button.

    Allan

  • GargiucnGargiucn Posts: 113Questions: 32Answers: 0

    Thanks,
    if I have understood correctly this refers to the opening of a pdf in an iframe when I click on a button.
    I am referring to opening files inserted in a table via file upload.
    Is this the same thing?

  • allanallan Posts: 64,892Questions: 1Answers: 10,747 Site admin

    Oh I see - I thought you were referring to the PDF export button, sorry.

    There are a few ways to do what you want, but none of them specific to DataTables:

    1. Use Javascript to open a new tab and then create the document with the iframe and a suitable src address for it.
    2. Create a link that points to a page that will display the iframe - you could potentially pass the src parameter as part of the request and have the HTML for it built directly (which would save having one page per link!).

    These are how you would do it with or without DataTables.

    Allan

Sign In or Register to comment.