PDFTK旋转页面问题

发布于 2024-09-07 00:55:40 字数 537 浏览 7 评论 0原文

我正在尝试使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

勿挽旧人 2024-09-14 00:55:40

将第 1 页顺时针旋转 90 度:

pdftk in.pdf cat 1E output out.pdf    # old pdftk
pdftk in.pdf cat 1east output out.pdf # new pdftk

顺时针旋转所有页面:

pdftk in.pdf cat 1-endE output out.pdf    # old pdftk
pdftk in.pdf cat 1-endeast output out.pdf # new pdftk

同样,逆时针旋转所有页面:

 pdftk in.pdf cat 1-endwest output out.pdf

更新 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:

pdftk in.pdf cat 1E output out.pdf    # old pdftk
pdftk in.pdf cat 1east output out.pdf # new pdftk

To rotate all pages clockwise:

pdftk in.pdf cat 1-endE output out.pdf    # old pdftk
pdftk in.pdf cat 1-endeast output out.pdf # new pdftk

Similarly, to rotate all pages anti-clockwise:

 pdftk in.pdf cat 1-endwest output out.pdf

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

睡美人的小仙女 2024-09-14 00:55:40

当您使用“正常”旋转参数(N、E、S、W)时,您将 PDF 页面上的旋转标志设置为您的参数(例如 90 度)。这不考虑当前的旋转设置。这是 pdftk 文档中有关旋转的段落:

页面旋转设置可能会导致 pdftk 旋转页面并
文件。每个选项设置页面旋转如下(在
度):N:0,E:90,S:180,W:270,L:-90,R:+90,D:
+180。 L、R 和 D 对页面的旋转进行相对调整。

除了 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:

The page rotation setting can cause pdftk to rotate pages and
documents. Each option sets the page rotation as follows (in
degrees): N: 0, E: 90, S: 180, W: 270, L: -90, R: +90, D:
+180. L, R, and D make relative adjustments to a page's 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).

缘字诀 2024-09-14 00:55:40

pdftk 在您的发行版中不再可用,或者它的选择性页面旋转(而不是整个文档旋转)也不适合您时,qpdf 是一个很好、快速的替代品。
它在网络作为 pdf

来自文档:

--rotate=[+|-]angle[:page-range]

对指定页面应用旋转。选项值的页面范围部分与第 3.5 节“页面选择选项”中的页面范围具有相同的格式。如果省略页面范围,则旋转将应用于所有页面。参数的角度部分可以是 90、180 或 270。如果前面有 + 或 -,则将在指定页面的原始旋转中添加或减去角度。否则,页面的旋转将设置为精确值。例如,命令 qpdf in.pdf out.pdf --rotate=+90:2,4,6 --rotate=180:7-8 会将第 2、4 和 6 页旋转 90 度从原始旋转角度顺时针旋转 180 度,并强制第 7 到 9 页旋转 180 度,无论其原始旋转如何,命令 qpdf in.pdf out.pdf --rotate=180 将旋转所有页面180 度。

我不隶属于 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]

Apply rotation to specified pages. The page-range portion of the option value has the same format as page ranges in Section 3.5, “Page Selection Options”. If the page range is omitted, the rotation is applied to all pages. The angle portion of the parameter may be either 90, 180, or 270. If preceded by + or -, the angle is added to or subtracted from the specified pages' original rotations. Otherwise the pages' rotations are set to the exact value. For example, the command qpdf in.pdf out.pdf --rotate=+90:2,4,6 --rotate=180:7-8 would rotate pages 2, 4, and 6 90 degrees clockwise from their original rotation and force the rotation of pages 7 through 9 to 180 degrees regardless of their original rotation, and the command qpdf in.pdf out.pdf --rotate=180 would rotate all pages by 180 degrees.

I'm not affiliated with the qpdf project, but I'm glad I found a good and really fast pdftk alternative.

眉黛浅 2024-09-14 00:55:40

最受好评的答案在我的情况下不起作用。

我必须使用以下方法向右旋转 90 度:

    pdf2tk input.pdf cat 1right output outrot90.pdf

当我使用 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:

    pdf2tk input.pdf cat 1right output outrot90.pdf

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文