java实现pdf旋转,通过itext pdf库进行图像旋转

在Java程序中使用iText PDF库旋转图像时,图像的旋转点默认为左下角。要改变旋转点,需利用低级功能调整CTM,例如使用PdfContentByte类的不同addImage()方法,结合AffineTransform或CTM矩阵来定义旋转。PDF的坐标系统以MediaBox的左下角为原点,旋转是通过对坐标系统而非对象本身进行操作来实现的。
摘要由CSDN通过智能技术生成

I am unable to rotate image from center or any fixed point by using itext pdf library in java program.When i rotate image it's x and y cordinate gets changed. Kindly help me in this regard.

Image pdfImage=Image.getInstance("assets/product.png");

pdfImage.setAlignment(Element.ALIGN_CENTER);

pdfImage.setRotationDegrees(30);

document.add(pdfImage);

pdfImage.setRotationDegrees(140);

document.add(pdfImage);

In above code there is no same point by which I can judge the rotation point.

Thanks in advance

解决方案

When you set a rotation using the setRotationDegrees() method, the image is rotated using the lower-left corner of the image as its rotation point. If you want another rotation point, you'll need to work with low-level functionality to change the CTM. See the different addImage() methods in the PdfCon

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值