2448 X 3264 add image problem
Closed this issue · 5 comments
2448 X 3264 add image not being saved in pdf with correct orientation. I tried alll possible ways. .
Below is the code which i am attempting
var pdf = new jsPDF();
var img = document.getElementById('blah');
var left = 15, top = 40;
var imgData = $('#blah').attr('src');
var width = pdf.internal.pageSize.getWidth();
var maxWidth = (width - left * 2);
var newWidth = img.naturalWidth < maxWidth ? img.naturalWidth : maxWidth;
var newHeight = img.naturalHeight * newWidth / img.naturalWidth;
var left = 15, top = 40;
var pdf = new jsPDF('p', 'px', [img.naturalHeight + top * 2, img.naturalWidth + left * 2]);
pdf.setFontSize(40);
pdf.text(35, 25, "Octonyan loves jsPDF");
pdf.addImage(imgData, 'JPEG', left, top, img.naturalWidth, img.naturalHeight);
pdf.save();
Please find below image which I am using -
When I am using addimage function with 2448 * 3264 dimensions of JPEG image, its getting rotated 270 degree clockwise automatically. Could you please help me why its getting rotated.
Seems to be a bug... I will investigate this when I find the time.
No, this is NOT a bug of JsPDF. The image itself is rotated 90 degrees. You should check the image EXIF data, do not simply rely on the file property from Windows, which automatically rotates the image for you. Check this URL out. Attached is a screenshot from verexif.com.
This is more like a Stack Overflow question instead of a GitHub issue to me.
This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.

