如何查找PDF是横向还是纵向 [英] How to find whether PDF has landscape orientation or portrait

查看:1167
本文介绍了如何查找PDF是横向还是纵向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有工具来确定PDF是横向还是纵向?

Are there tools to determine whether a PDF has landscape orientation or portrait?

我目前正在查看 pdfbox Itext 为此,但似乎我找不到它。请告诉他们是否支持此功能。

I have currently looked upon pdfbox and Itext for this but seem that I could not find it. Please tell if they support this.

使用 Origami 提取PDF页面信息,提供pdf页面在某种程度上具有轮换效果的信息。这是Origami报道的内容:

Extracting the PDF pages information using Origami is providing a information the pdf pages have rotation of some degree. Here is what Origami reports:

{:Parent=>#<PDF::Reader::Reference:0x872349c @id=8, @gen=0>, :Type=>:Page, 
 :Contents=>#<PDF::Reader::Reference:0x8722f24 @id=4, @gen=0>, :Resources=># <PDF::Reader::Reference:0x870dbd8 @id=2, @gen=0>, 
:MediaBox=>[0, 0, 612, 792], :Rotate=>270}

轮流:270

'轮换'实际意味着什么?

What does the 'rotation' actually mean?

推荐答案

pdfinfo 命令行实用程序有一种方法可以让您查看页面大小信息以及每个页面的MediumBox,CropBox,BleedBox,ArtBox和TrimBox值。在这里,我询问特定文档第2页到第4页的值:

The pdfinfo commandline utility has a way to let you see the page size info and MediumBox, CropBox, BleedBox, ArtBox and TrimBox values for each and every page. Here I ask about the values for pages 2 to 4 of a specific document:

pdfinfo -box -f 2 -l 4 sample.pdf
  Creator:        FrameMaker 6.0
  Producer:       Acrobat Distiller 5.0.5 (Windows)
  CreationDate:   Thu Aug 17 16:43:06 2006
  ModDate:        Tue Aug 22 12:20:24 2006
  Tagged:         no
  Form:           AcroForm
  Pages:          146
  Encrypted:      no
  Page    2 size: 419.535 x 297.644 pts
  Page    2 rot:  90
  Page    3 size: 297.646 x 419.524 pts
  Page    3 rot:  0
  Page    4 size: 297.646 x 419.524 pts
  Page    4 rot:  0
  Page    2 MediaBox:     0.00     0.00   595.00   842.00
  Page    2 CropBox:     87.25   430.36   506.79   728.00
  Page    2 BleedBox:    87.25   430.36   506.79   728.00
  Page    2 TrimBox:     87.25   430.36   506.79   728.00
  Page    2 ArtBox:      87.25   430.36   506.79   728.00
  Page    3 MediaBox:     0.00     0.00   595.00   842.00
  Page    3 CropBox:    148.17   210.76   445.81   630.28
  Page    3 BleedBox:   148.17   210.76   445.81   630.28
  Page    3 TrimBox:    148.17   210.76   445.81   630.28
  Page    3 ArtBox:     148.17   210.76   445.81   630.28
  Page    4 MediaBox:     0.00     0.00   595.00   842.00
  Page    4 CropBox:    148.17   210.76   445.81   630.28
  Page    4 BleedBox:   148.17   210.76   445.81   630.28
  Page    4 TrimBox:    148.17   210.76   445.81   630.28
  Page    4 ArtBox:     148.17   210.76   445.81   630.28
  Page    4 MediaBox:     0.00     0.00   595.00   842.00
  File size:      6888764 bytes
  Optimized:      yes
  PDF version:    1.4

请注意以下事项:


  • * Box values:这些是4个数字,单位是PostScript点:第一对代表左下角的坐标,第二对代表右上角的nts坐标。

  • *Box values: these are 4 numbers whose units are PostScript points: the first pair represents the coordinates of the lower left corner, the second pair represents coordinates of the upper right corner.

MediaBox :是否需要 为PDF中的每个页面设置。

MediaBox: Is a required setting for each page inside the PDF.

TrimBox :是可选

TrimBox: Is an optional setting and defaults to the same as MediaBox if it is not explicitly defined. If it deviates from the MediaBox, then it tells PDF viewers (and printer drivers) to only render and display that particular part of the full page.

页面大小:此信息是根据TrimBox值设置的距离导出+计算的。

Page size: This info is derived + computed from the distances that are set up by the TrimBox value.

rot :这给出了页面旋转的值。可能 0 90 180 270 度。

rot: This gives the value of the page rotation. May be 0, 90, 180 or 270 degrees.

现在,页面的风景 portrait 定义如下:

Now, the page's landscape and portrait definitions are this:


  • 如果宽度大于高度。

  • 如果高度大于宽度,则视为肖像。

  • 如果宽度和高度有,则不确定相同的价值。

但是!,....


  • ...您可以将非零 / Rotation 值添加到您的PDF源代码中( pdfinfo 将显示为 rot: info)并以此方式实现纵向PDF页面将显示为横向和反之亦然;

  • ...you can put a non-zero /Rotation value into your PDF source code (which pdfinfo will show as rot: info) and achieve this way that a 'portrait' PDF page will display as 'landscape' and vice-versa;

...你可以在'肖像'形状内定义'风景'形状'/ TrimBox / MediaBox`或反之亦然,以及将其与非零旋转和ach混合这样,风景形状的内容将以肖像(或颠倒)的形式显示......

...you could define a 'landscape' shaped '/TrimBoxinside a 'portrait' shaped/MediaBox` or vice versa, as well as mix it with a non-zero rotation, and achieve this way that the 'landscape' shaped content will appear in 'portrait' (or upside-down) look...

对此感到困惑?别担心,很多都是。事实上,风景和肖像并不是明确且毫不含糊地定义的技术术语。它们只是描述我们看到的内容的惯例......

Confused about this? Don't worry, many are. Fact is, 'landscape' and 'portrait' aren't clearly and un-ambiguously defined technical terms. They are just conventions to describe what we see...

这篇关于如何查找PDF是横向还是纵向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆