sanjshah12
asked on
JS to take screenshot of a page div
Hi,
I am looking to see if it is possible to take a screenshot of the div that contains an iframe displaying a PDF.
I have found a few JS scripts that take a screenshot but the fail (do not include) the contents of an iframe displaying a PDF.
Any help is appreciated.
I am looking to see if it is possible to take a screenshot of the div that contains an iframe displaying a PDF.
I have found a few JS scripts that take a screenshot but the fail (do not include) the contents of an iframe displaying a PDF.
Any help is appreciated.
Hi,
html2canvas is supporting Iframe
https://github.com/niklasvh/html2canvas
https://html2canvas.hertzen.com/
https://github.com/niklasvh/html2canvas/blob/master/CHANGELOG.md
I have not tested with PDF or data from other source, I guess this should work if this is on the same server.
html2canvas is supporting Iframe
https://github.com/niklasvh/html2canvas
https://html2canvas.hertzen.com/
https://github.com/niklasvh/html2canvas/blob/master/CHANGELOG.md
I have not tested with PDF or data from other source, I guess this should work if this is on the same server.
To add to what Jim has already explained, if it is a PDF, no matter from where it is being loaded and how it is being loaded, you won't be able to capture it as a screenshot using JavaScript.
PS: I would love to be wrong but this is how it is. Someday, security by obscurity will give way to common sense and ease of use. *fingers crossed*
PS: I would love to be wrong but this is how it is. Someday, security by obscurity will give way to common sense and ease of use. *fingers crossed*
ASKER
Thanks for your replies.
I will download HTML2canvas and test and revert back.
While I test that script would anyone know of any other MVC component that would allow me to take a screen grab?
Thanks
I will download HTML2canvas and test and revert back.
While I test that script would anyone know of any other MVC component that would allow me to take a screen grab?
Thanks
ASKER
Hi lenamtl,
I tried with the html2canvas but the pdf in the iframe does not work. The pdf is in the same folder as the document.
https://www.experts-exchange.com/questions/29124933/JS-to-take-screenshot-of-a-page-div.html?anchorAnswerId=42727489#a42727489
Regards
I tried with the html2canvas but the pdf in the iframe does not work. The pdf is in the same folder as the document.
https://www.experts-exchange.com/questions/29124933/JS-to-take-screenshot-of-a-page-div.html?anchorAnswerId=42727489#a42727489
Regards
Hi,
Do you render the PDF or the PDF is already render?
Maybe you will be able to do it when you render the PDF, if you can render it.
Could you explain why you need this feature so we can find another way to get similar result..
Does the content of the PDF can be recreate using PHP / Ajax DB ?
Are you using server side language like PHP?
You may want to check this
https://github.com/tsayen/dom-to-image
*Note when using canva sometimes the result is not very good can be blurry or have unwanted black area.
Do you render the PDF or the PDF is already render?
Maybe you will be able to do it when you render the PDF, if you can render it.
Could you explain why you need this feature so we can find another way to get similar result..
Does the content of the PDF can be recreate using PHP / Ajax DB ?
Are you using server side language like PHP?
You may want to check this
https://github.com/tsayen/dom-to-image
*Note when using canva sometimes the result is not very good can be blurry or have unwanted black area.
ASKER
Many thanks lenamtl for replying.
The PDF is in an iFrame (all on the same domain).
I will check dom-to-img.
Thanks
The PDF is in an iFrame (all on the same domain).
I will check dom-to-img.
Thanks
ASKER
Apologies I have still not been able to get this working with pdf either embedded or an Iframe.
I have attached an example in case it helps.
https://www.dropbox.com/s/qy06giwz7lvktnh/Sample.zip?dl=0
Thanks
I have attached an example in case it helps.
https://www.dropbox.com/s/qy06giwz7lvktnh/Sample.zip?dl=0
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, lenamtl, let me check to convert the pdf to images as per the links.
Thanks
Thanks
That is likely why any scripts you find are unable to create a screen capture of the IFRAME contents.