全手動旋轉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 β.

效果如下:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章