PDFTK旋转页面问题
我正在尝试使用 PDFTK 来旋转 PDF 文档中的页面。执行类似以下的操作应该不会导致页面旋转发生任何变化:(
pdftk in.pdf cat 1N output out.pdf
这是将第 1 页旋转“北”或“0 度”。)
在某些 PDF 测试文档中,它会按预期工作(意味着页面不会发生任何变化) )。然而,在某些测试文档上,PDF文档被旋转90度。我尝试进行的任何页面旋转都会始终应用额外的 90 度。因此,如果我这样做:(
pdftk in.pdf cat 1E output out.pdf
这是将第 1 页旋转“东”或“90 度”。)结果是页面旋转 180 度 - 额外旋转 90 度!
在 Acrobat Reader 中查看时,PDF 看起来不错。
这些问题测试 PDF 文档的唯一区别是我使用 Acrobat Pro 已经更改了它们的旋转。当对这些已经旋转的 PDF 文档应用 PDFTK 页面旋转时,我遇到了这个问题。
知道发生了什么事吗?
I'm trying to use PDFTK to rotate pages in my PDF document. Executing something like the following should result in no changes to the page rotation:
pdftk in.pdf cat 1N output out.pdf
(This is rotating page 1 "north" or "0 degrees.")
In some PDF test documents, it works as expected (meaning, no changes to the page occurs). However, on some test documents, the PDF document is rotated 90 degrees. An additional 90 degrees is consistently applied to any page rotation I attempt to do. So, if I do this:
pdftk in.pdf cat 1E output out.pdf
(This is rotating page 1 "east" or "90 degrees.") The result is the page is rotated 180 degrees -- an additional 90 degrees!
The PDF looks OK when viewed in Acrobat Reader.
The only difference with these problem test PDF documents is that I used Acrobat Pro to already change their rotation. When applying PDFTK page roation on these already rotated PDF documents, I run into this problem.
Any idea what's going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将第 1 页顺时针旋转 90 度:
顺时针旋转所有页面:
同样,逆时针旋转所有页面:
更新 08Oct2023
在阅读了各种评论并体验了我的自己的 pdf,有时由于 pdf 自己的方向元数据,相对旋转命令更好。对我来说,南、西、东没有按预期工作,所以我必须使用相关命令。
下面我举个例子:
左为左旋转,右为右旋转,下为旋转。 (短代码 L、R、D 也不起作用)。
在下面的示例中,我将第 11、17-18、24-26 页向右旋转,即顺时针旋转页面 90dec。类似地,您可以使用向左和向下。
PS D:\tmp> pdftk in.pdf cat 1-10 11right 12-16 17-18right 19-23 24-26right 27端输出out.pdf
To rotate page 1 by 90 degrees clockwise:
To rotate all pages clockwise:
Similarly, to rotate all pages anti-clockwise:
Update 08Oct2023
After reading various comments and having experienced with my own pdf, sometimes the relative rotation commands are better due to the pdf's own orientation metadata. for me south, west, east, didn't work as expected, so I have to use relative commands.
I will given an example of it below:
left to rotate left, right to rotate right, down to rotate. (Also short codes L, R, D did not work).
in below example, I am rotating page 11, 17-18, 24-26 to right, that is rotate the page 90dec clockwise. Similary you can use left and down.
PS D:\tmp> pdftk in.pdf cat 1-10 11right 12-16 17-18right 19-23 24-26right 27-end output out.pdf
当您使用“正常”旋转参数(N、E、S、W)时,您将 PDF 页面上的旋转标志设置为您的参数(例如 90 度)。这不考虑当前的旋转设置。这是 pdftk 文档中有关旋转的段落:
除了 NESW 旋转设置之外,您还可以使用 L、R 和 D 选项,这些选项允许您在考虑当前旋转标志的情况下进行相对调整。
如果这不能解决您的问题,我需要访问几个测试文档(一个可以正常工作,另一个会导致错误的旋转设置)。
When you use the "normal" rotation parameters (N, E, S, W), you are setting the rotation flag on the PDF pages to your parameter (e.g. 90 degrees). This does not take into account the current rotation setting. Here is the paragraph from the pdftk documentation about rotation:
In addition to the NESW rotation settings, you also have the L, R and D options, that allow you to make relative adjustments that take the current rotation flag into account.
If that does not solve your problem, I would need access to a couple of test documents (one that does work correctly, and one that results in the wrong rotation setting).
当
pdftk
在您的发行版中不再可用,或者它的选择性页面旋转(而不是整个文档旋转)也不适合您时,qpdf
是一个很好、快速的替代品。它在网络和作为 pdf。
来自文档:
--rotate=[+|-]angle[:page-range]
我不隶属于 qpdf 项目,但我很高兴我找到了一个很好且非常快的 pdftk 替代品。
When
pdftk
is no longer available in your distribution, or it's selective-page rotation (as opposed to whole-document rotation) doesn't work for you either,qpdf
is a good, fast, replacement.It has good documentation on the web and as pdf.
From the documentation:
--rotate=[+|-]angle[:page-range]
I'm not affiliated with the qpdf project, but I'm glad I found a good and really fast pdftk alternative.
最受好评的答案在我的情况下不起作用。
我必须使用以下方法向右旋转 90 度:
当我使用 1-endeast 时,pdf 旋转了 180 度,正如原始海报所述。我怀疑这是由于 pdf 文件中存储的其他一些元数据造成的。
我正在使用 Pdftk 2.02
The most upvoted answer did not work in my situation.
I had to use the following to rotate right 90 degrees:
When I used 1-endeast, the pdf rotated 180 degrees just as the original poster stated. I suspect it is due to some other metadata stored in the pdf files.
I am using Pdftk 2.02