I have a HTML page with Iframe content and i am trying to export it to PDF.The export to PDF is working but the JS query does not pull the IFrame content into the PDF file.
The
tag content alone is been published in pdf file.
Below listed the code for references.
<html>
<body>
<div id="content">
<p> Hello </p>
<iframe src="https://app.powerbi.com/view?r=eyJrIjoiYjVjZTZkYjEtNWRiOC00ZTM2LWJiNGYtZTA0Y2I2YmFhN2Y4IiwidCI6ImJkMGQyNTQxLWEyZTAtNDE1Zi1hNTI2LTNkY2UxODFlMDM0OSIsImMiOjh9" style="height:750px;width:1550px;">
</iframe>
</div>
<div id="editor"></div>
<button id="cmd">Generate PDF</button>
<script src="https://code.jquery.com/jquery-1.12.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js"></script>
<Script>
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function(element, renderer) {
return true;
}
};
$('#cmd').click(function() {
doc.fromHTML($('#content').html(), 50, 50, {
'width': 170,
'height': 170,
'elementHandlers': specialElementHandlers
});
doc.save('sample-file.pdf');
});
function getFrameContents() {
var iFrame = document.getElementById('#content');
var iFrameBody;
if (iFrame.contentDocument) { // FF
iFrameBody = iFrame.contentDocument.getElementsByTagName('#content')[1];
} else if (iFrame.contentWindow) { // IE
iFrameBody = iFrame.contentWindow.document.getElementsByTagName('#content')[1];
}
//alert(iFrameBody.innerHTML);
return iFrameBody.innerHTML
}
</Script>
</body>
</html>