There are 3 different ways to do a landscape page, and all three are used (I'm using 8.5x11 as a basis here, YMMV): 11x8.5(这些页面看起来正确". 8.5x11 90顺时针 8.5x11 90逆时针因此,您需要检查页面的旋转情况.So you need to check the page's rotation.int rot = PdfReader.getPageRotation(pageNum);如果您想让印章呈现偶数",则需要基于该旋转对其进行变换.基本的转换是这样的:If you want your stamp to come out "even" you then need to transform it based on that rotation. The basic transform goes something like this:cos(rot), sin(rot), -sin(rot), cos(rot), xoff, yoff旋转围绕原点,即0,0.您需要xoff和yoff才能将图章移回所需位置.因为可以组合转换,所以一个常见的技巧是:Rotation takes place around the origin, 0,0. You need xoff and yoff to move the stamp back to where you want it. Because you can combine transformations, one common trick is:移动对象,使其以原点为中心.旋转将其移回去.以适当的顺序组合这三个单独的转换时,最终会得到一个可以满足您需要的转换.When you combine those three individual transformations in the proper order, you end up with a single transform that does just what you want.或者您可以作弊并使用AffineTransform.getRotateInstance( theta, centerX, centerY),但是这样做的乐趣在哪里? PdfContentByte.transform(AffineTransform)会为您吸取数组,但是所有元素都以正确的顺序简单地将它们传递给接受转换为六个浮点数的任何内容字节函数(这些参数通常称为"a,b之类的东西,c,d,h,v").Or you could cheat and use AffineTransform.getRotateInstance( theta, centerX, centerY), but where's the fun in that? PdfContentByte.transform(AffineTransform) will suck the array out for you, but all the elements are in the proper order to simply pass them to any of the content byte functions that accepts a transformation as six floats (the parameters are usually called something like "a, b, c, d, h, v"). 这篇关于iText setRotateContents(false)在Landscape PDF上的奇怪行为?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 18:19