全手动旋转PDF文档内置的图片

扫描的PDF页面是斜的,用软件自动纠偏效果很差,于是想到了之前的方法:

  1. 先deflate手里的pdf;
  2. 然后找到图片对应的页面
  3. 添加q...Q行,然后在其中间添加cm命令,控制图像本身。
% 25 0 obj
% << /Length 107 >>
% stream
   q
      0.480000 0 0 0.480000 0 0 cm
      1 -0.01 0 1 0 0 cm % page 5
      1240 0 0 1753 0 0 cm
      /Im5 Do
   Q
% endstream
命令 解释
1 -0.01 0 1 0 0 cm % page 5 transformation matrices(CTM)
q,Q,cm special graphics state
  • Translations are specified as [1 0 0 1 tx ty ], where tx and ty are the distances
    to translate the origin of the coordinate system in the horizontal and vertical
    dimensions, respectively.
  • Scaling is 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 are produced by [cosθ sinθ −sinθ cosθ 0 0], which has the effect
    of rotating the coordinate system axes by an angleθ counterclockwise.
  • Skew is specified by [1 tanα tanβ 1 0 0], which skews the x axis by an angleα and the y axis by an angle β.
image.png

效果如下:

image.png
image.png

你可能感兴趣的:(全手动旋转PDF文档内置的图片)