I have content displayed on a webpage with images, each image having a specific width or none specified. When a user clicks a button, the content is exported to a PDF file. To ensure the images fit correctly on the PDF page, I adjust their width and height. However, this adjustment also affects the images on the webpage itself. How can I prevent this from happening?
You can see a demonstration here: https://plnkr.co/edit/STVjUB1YMwbOrtYLxR8V?p=preview
In the demo above, when you click on the export button, the image dimensions are altered to ensure they fit properly in the PDF file. Unfortunately, these changes also impact the images displayed on the webpage. Is there a way to apply the modified dimensions only to the PDF file without affecting the webpage?
Here is an example of the HTML code:
<button ng-click="export()">export</button>
<div class="myDivClass"..>
<img src="data:image/jpeg..">
<img src="..." style="width:400px">
..
//content
</div>
And here is the corresponding JavaScript code:
$scope.export = function() {
var imagesToResize = document.getElementsByTagName("img");
for(i=0;i<imagesToResize.length;i++){
imagesToResize[i].style.width = "100px";
imagesToResize[i].style.height = "100px";
}
Any suggestions on how to address this issue would be greatly appreciated.