我可以创建一个始终以缩放级别100%打开的PDF吗? [英] Can I create a PDF which will always opens at zoom level 100%?

查看:190
本文介绍了我可以创建一个始终以缩放级别100%打开的PDF吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了PNG到PDF转换的问题。

I am running into an issue with PNG to PDF conversion.

实际上我的PNG文件大小不是很大但内容很多。

Actually I have big PNG files not in size but in contents.

在PDF转换中,它会创建一个大的PDF文件。我的质量没有任何问题,但每当我尝试在PDF查看器中打开此PDF时,它都会以适合页面模式打开。

In PDF conversion it creates a big PDF files. I don't have any issue with its quality, but whenever I try to open this PDF in PDF viewer, it opens in "Fit to Page" mode.

因此,我无法在初始视图中看到创建的PDF,但我需要将其缩放到100%。

So, I can't see the created PDF in the initial view, but I need to zoom it up to 100%.

我的问题是:我可以创建一个始终以缩放100%打开的PDF吗?

My question is: can I create a PDF which will always open at zoom 100% ?

推荐答案

你可以在Ghostscript的帮助下实现你想要的。

You can possibly achieve what you want with the help of Ghostscript.

Ghostscript支持通过 -c将PostScript片段插入其命令行参数中。 。[此处为PostScript代码] ...

Ghostscript supports to insert PostScript snippets into its command line parameters via -c "...[PostScript code here]...".

PostScript有一个名为的特殊运算符pdfmark 。大多数PostScript解释器都不理解这个操作符,但是在生成PDF时,Acrobat Distiller和(对于大多数参数)也可以通过Ghostscript理解。

PostScript has a special operator called pdfmark. This operator is not understood by most PostScript interpreters, but is understood by Acrobat Distiller and (for most of its parameters) also by Ghostscript when generating PDFs.

所以你可以试试插入

-c "[ /PageMode /UseNone /Page 1 /View [/XYZ null null 1] \
      /PageLayout /SinglePage /DOCVIEW pdfmark"

进入PDF-> PDF转换Ghostscript命令行。

into a PDF->PDF conversion Ghostscript command line.

请注意有关此代码段的各种基本内容:

Please take note about various basic things concerning this snippet:


  1. 关于 [] 运营商/关键字。但事实并非如此!最初的[由最终的 pdfmark 关键字平衡。 (不要问 - 我没有定义这种语法......)

  1. The contents of the command line snippet appears to be 'unbalanced' regarding the [ and ] operators/keywords. But it is not! The initial [ is balanced by the final pdfmark keyword. (Don't ask -- I did not define this syntax...)

'内部' [...] 括号分隔数组,表示您想要的页面 / View 设置。

The 'inner' [ ... ] brackets delimit an array representing the page /View settings you desire.

并非所有PDF查看器都尊重PDF文件中嵌入的视图设置(Acrobat软件会这样做!)。

Not all PDF viewers do respect the view settings embedded in the PDF file (Acrobat software does!).

大多数PDF查看器允许用户覆盖PDF文件中嵌入的视图设置(Acrobat软件也可以这样做)。也就是说,你可以告诉你的观众从不尊重它打开的PDF文件中的任何设置,但是f.e.始终以适合宽度打开它。

Most PDF viewers allow users to override the view settings embedded in PDF files (Acrobat software also does this). That is, you can tell your viewer to never respect any settings from the PDF files it opens, but f.e. to always open it with "fit to width".

关于此片段的一些具体事项:

Some specific things about this snippet:


  1. 页面模式 / UseNone 表示:文档显示时没有书签或缩略图。它可以被

    • / UseOutlines 替换(以显示书签,而不仅仅是页面)

    • / UseThumbs (显示页面的缩略图,而不仅仅是页面

    • / FullScreen (以全屏模式打开文档)

  1. The page mode /UseNone means: the document displays without bookmarks or thumbnails. It could be replaced by
    • /UseOutlines (to display bookmarks also, not just the pages)
    • /UseThumbs (to display thumbnail images of the pages, not just the pages
    • /FullScreen (to open document in full screen mode)

    / Fit (使页面适应当前窗口大小)
  • / FitB (使可见页面内容适应当前窗口大小)

  • / FitH< top>'(使页面宽度适应当前窗口) width); `表示距离pa所需的距离ge起源于窗口的上边缘。

  • ...以及其他几个我现在都记不住的了。

  • /Fit (to adapt the page to the current window size)
  • /FitB (to adapt the visible page content to the current window size)
  • /FitH <top>' (to adapt the page width to the current window width);` indicates the required distance from page origin to upper edge of window.
  • ...plus several others I cannot remember right now.

因此,要更改现有PDF文件的设置,您可以执行以下操作:

So to change the settings of an existing PDF file, you could do the following:

gs                                                              \
  -o out.pdf                                                    \
  -sDEVICE=pdfwrite                                             \
  -c "[ /PageMode /UseNone /Page 1 /View [ /XYZ null null 1 ] " \
  -c "  /PageLayout /SinglePage /DOCVIEW pdfmark"               \
  -f in.pdf

要检查Ghostscript命令是否有效,请在能够处理二进制文件的文本编辑器中打开PDF。搜索 /查看 / PageMode 关键字并检查它们是否存在,作为值插入PDF根目录对象。

To check if the Ghostscript command worked, open the PDF in a text editor which is capable of handling binary files. Search for the /View or the /PageMode keywords and check if they are there, inserted as values into the PDF root object.

如果有效,请检查您的PDF查看器是否符合设置。如果它不尊重它们,请查看查看器首选项设置中是否存在覆盖设置。

If it worked, check if your PDF viewer honors the settings. If it doesn't honor them, see if there is an overriding setting within the viewers preference settings.

我对我的示例PDF进行了快速测试。以下是PDF根对象的字典现在的样子,借助 pdf-parser.py

I did a quick test run on a sample PDF of mine. Here is how the PDF root object's dictionary looks now, checked with the help of pdf-parser.py:

pdf-parser-beta.py -s Catalog a.pdf
 obj 1 0
  Type: /Catalog
  Referencing: 3 0 R, 9 0 R

   <<
     /Type       /Catalog
     /Pages      3 0 R
     /PageMode   /UseNone
     /Page       1
     /View       [/XYZ null null 1]
     /PageLayout /SinglePage
     /Metadata   9 0 R
   >>

要了解有关pdfmark运算符的更多信息,请访问'pdfmark参考文件类型:pdf'的。您应该可以在Adobe网站和其他地方找到它:

To learn more about the pdfmark operator, google for 'pdfmark reference filetype:pdf'. You should be able to find it on the Adobe website and elsewhere:

  • https://www.google.de/search?q=pdfmark%20reference%20filetype%3Apdf&oq=pdfmark%20reference%20filetype%3Apdf

为了让ImageMagick根据需要创建PDF,您可能能够破解定义委托设置的文件。有关此主题的更多帮助,请参见此处:

In order to let ImageMagick create a PDF as you want it, you may be able to hack the file defining your delegate settings. For more help about this topic see for example here:

  • http://www.imagemagick.org/Usage/files/#delegates

这篇关于我可以创建一个始终以缩放级别100%打开的PDF吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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