如何设置初始视图属性? [英] How to set initial view properties?

查看:314
本文介绍了如何设置初始视图属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我想在acrobat中的初始视图标签下设置已存在的PDF文档属性。

Here I want to set the already exist PDF document properties under Initial View tab in acrobat.

文档选项:


  • 显示=书签面板和页面

  • 页面布局=连续

  • 放大率=适合宽度

  • 打开到页码= 1

  • Show = Bookmarks Panel and Page
  • Page Layout = Continuous
  • Magnification = Fit Width
  • Open to Page number = 1

窗口选项:


  • 显示=文档标题

如以下屏幕截图所示:

我尝试使用以下代码:

PdfStamper stamper = new PdfStamper(reader, new FileStream(dPDFFile, FileMode.Create));
stamper.AddViewerPreference(PdfName.DISPLAYDOCTITLE, new PdfBoolean(true));

以上代码用于设置文档标题显示。

the above code is used to set the document title show.

但以下代码无法正常工作

对于页面布局:

stamper.AddViewerPreference(PdfName.PAGELAYOUT, new PdfName("OneColumn"));

对于书签面板和页面:

stamper.AddViewerPreference(PdfName. PageMode, new PdfName("UseOutlines"));

所以请指导我,以满足我的要求的正确方法。

So please give guide me what is the correct way to meet my requirement.

推荐答案

我在回答上一个答案的评论中的额外问题时添加了额外的答案:

I'm adding an extra answer in answer to the extra question in the comments of the previous answer:

如果你有一个名为 writer PdfWriter 实例,你可以像这样设置Viewer首选项: / p>

When you have a PdfWriter instance named writer, you can set the Viewer preferences like this:

writer.ViewerPreferences = viewerpreference;

在这种情况下, viewerpreference 是一个可以具有以下值之一的值:

In this case, the viewerpreference is a value that can have one of the following values:


  • PdfWriter.PageLayoutSinglePage

  • PdfWriter.PageLayoutOneColumn

  • PdfWriter.PageLayoutTwoColumnLeft

  • PdfWriter.PageLayoutTwoColumnRight

  • PdfWriter.PageLayoutTwoPageLeft

  • PdfWriter.PageLayoutTwoPageRight

  • PdfWriter.PageLayoutSinglePage
  • PdfWriter.PageLayoutOneColumn
  • PdfWriter.PageLayoutTwoColumnLeft
  • PdfWriter.PageLayoutTwoColumnRight
  • PdfWriter.PageLayoutTwoPageLeft
  • PdfWriter.PageLayoutTwoPageRight

有关详细信息,请参阅 PageLayoutExample

See the PageLayoutExample for more info.

您还可以更改页面模式,如 ViewerPreferencesExample 。在这种情况下,不同的值是OR-ed:

You can also change the page mode as is shown in the ViewerPreferencesExample. In which case the different values are "OR"-ed:


  • PdfWriter.PageModeFullScreen

  • PdfWriter.PageModeUseThumbs

  • PdfWriter.PageLayoutTwoColumnRight | PdfWriter.PageModeUseThumbs

  • PdfWriter.PageModeFullScreen | PdfWriter.NonFullScreenPageModeUseOutlines

  • PdfWriter.FitWindow | PdfWriter.HideToolbar

  • PdfWriter.HideWindowUI

  • PdfWriter.PageModeFullScreen
  • PdfWriter.PageModeUseThumbs
  • PdfWriter.PageLayoutTwoColumnRight | PdfWriter.PageModeUseThumbs
  • PdfWriter.PageModeFullScreen | PdfWriter.NonFullScreenPageModeUseOutlines
  • PdfWriter.FitWindow | PdfWriter.HideToolbar
  • PdfWriter.HideWindowUI

目前,您只使用了官方文档中的PrintPreferences示例:

Currently, you've only used the PrintPreferences example from the official documentation:

writer.AddViewerPreference(PdfName.PRINTSCALING, PdfName.NONE);
writer.AddViewerPreference(PdfName.NUMCOPIES, new PdfNumber(3));
writer.AddViewerPreference(PdfName.PICKTRAYBYPDFSIZE, PdfBoolean.PDFTRUE); 

但在某些情况下,它更容易使用:

But in some cases, it's just easier to use:

writer.ViewerPreferences = viewerpreference;

请注意,官方文档是iText in Action - Second Edition。这些示例是用Java编写的,但您可以找到C#版本这里。有一本名为PDF的ABC的新书,但到目前为止只写了4章。您可以在此处找到更多信息: http://itextpdf.com/learn

Note that the official documentation is the book "iText in Action - Second Edition." The examples are written in Java, but you can find the C# version here. There is a new book in the works called "The ABC of PDF", but so far only 4 chapters were written. You'll find more info here: http://itextpdf.com/learn

关于创建 PdfDestination 的不同选项的部分已经出现在PDF的ABC中。

The part about the different options to create a PdfDestination is already present in "The ABC of PDF".

至于设置语言,这样做:

As for setting the language, this is done like this:

stamper.Writer.ExtraCatalog.Put(PdfName.LANG, new PdfString("EN"));

结果显示在以下屏幕截图中:

The result is shown in the following screen shot:

As你可以看到,现在有一个 Lang 条目,其值 EN 被添加到目录中。

As you can see, there is now a Lang entry with value EN added to the catalog.

这篇关于如何设置初始视图属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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