PDFBox Matrix 中的参数是什么意思

What does the arguments mean in PDFBox Matrix

我遵循了这个示例 Create landscape PDF and it works fine. I would now like to move the 0,0 reference from the lower left corner to the top left corner. To do that I need change contentStream.transform(new Matrix(0, 1, -1, 0, pageWidth, 0));. I've had a look at the documentation for PDFBox Matrix,它指定了 Matrix 的参数,如下所示。

public Matrix(float a,
      float b,
      float c,
      float d,
      float e,
      float f)
Creates a matrix with the given 6 elements.

但它并没有告诉我这 6 个不同的 arguments/elements 是做什么的。我猜一个与旋转有关,两个与在 X 和 Y 方向上移动参考有关。我在哪里可以找到描述参数的文档?

Where can I find a document that describes the arguments?

要查找的文档是 PDF 规范 (ISO 32000-1) 以及一些线性代数 101。

A transformation matrix in PDF shall be specified by six numbers, usually in the form of an array containing six elements. In its most general form, this array is denoted [a b c d e f]; it can represent any linear transformation from one coordinate system to another.

(第 8.3.3 节 - 常见转换)

其含义稍后解释:

PDF represents coordinates in a two-dimensional space. The point (x, y) in such a space can be expressed in vector form as [x y 1]. The constant third element of this vector (1) is needed so that the vector can be used with 3-by-3 matrices in the calculations described below.

The transformation between two coordinate systems can be represented by a 3-by-3 transformation matrix written as follows:

Because a transformation matrix has only six elements that can be changed, in most cases in PDF it shall be specified as the six-element array [a b c d e f].

Coordinate transformations shall be expressed as matrix multiplications:

(第 8.3.4 节 - 转换矩阵)

因此,当当前设置了转换 [a b c d e f] 并且您使用坐标 (x, y) 绘制内容时,它将出现在坐标 (x', y') where

常用的转换类型有:

  • Translations shall be specified as [1 0 0 1 tx ty], where tx and ty shall be the distances to translate the origin of the coordinate system in the horizontal and vertical dimensions, respectively.

  • Scaling shall be obtained by [sx 0 0 sy 0 0]. This scales the coordinates so that 1 unit in the horizontal and vertical dimensions of the new coordinate system is the same size as sx and sy units, respectively, in the previous coordinate system.

  • Rotations shall be produced by [cos(q) sin(q) -sin(q) cos(q) 0 0], which has the effect of rotating the coordinate system axes by an angle q counter clockwise.

  • Skew shall be specified by [1 tan(a) tan(b) 1 0 0], which skews the x axis by an angle a and the y axis by an angle b.

(第 8.3.3 节 - 常见转换)

如果您想要组合变换,只需按适当的顺序将矩阵相乘即可​​。