简体   繁体   English

jsPDF围绕自己的中心旋转图像

[英]jsPDF rotate an image around its own center

I am using jsPDF to create a PDF from existing objects in my canvas.我正在使用 jsPDF 从我的 canvas 中的现有对象创建 PDF。 Thus I have the coordinates and the rotation angle of my objects, I want to then add to my PDF.因此我有了对象的坐标和旋转角度,然后我想添加到我的 PDF 中。 However, every image doesn't rotate around its own center, thus it changes the coordinates drastically.但是,每个图像都不会围绕自己的中心旋转,因此它会极大地改变坐标。

var doc = new jsPDF('p', 'mm', 'a3');
doc.addImage(image, 'PNG', 100, 100, 52.916667, 52.916667, null, null, 45);
doc.save('a3.pdf');

Can somebody help me rotate the image around its own center?有人可以帮我围绕自己的中心旋转图像吗?

Here is a jsFiddle https://jsfiddle.net/bx0ucszo/6/这是一个 jsFiddle https://jsfiddle.net/bx0ucszo/6/

I have the same Issue, You can solve it by playing with the degrees in X and Y for the position.我有同样的问题,您可以通过使用 position 的 X 和 Y 度数来解决它。

Meaning that if when you rotate your img 45 degrees it descends some pixels on Y, my solution was to put a negative value for Y, for example -100 instead of 100这意味着如果当您将 img 旋转 45 度时,它会在 Y 上下降一些像素,我的解决方案是为 Y 设置一个负值,例如 -100 而不是 100

Hope it's usefull for you希望对你有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM