本文介绍如何使用 C# 更改打开 PDF 的设置。其中包括设置开发环境的详细信息、步骤列表以及使用 C# 更改在 Adobe 中打开 PDF 的设置的示例代码。示例代码将演示更改 PDF 打开设置的各种属性。
使用 C# 更改 PDF 打开设置的步骤
- 将 IDE 设置为使用 Aspose.PDF for .NET 来更改打开设置
- 将源 PDF 文件加载到 Document 对象中以更改打开设置
- 设置 Document 类中的各种属性来更改 PDF 查看首选项
- Save 输出 PDF 文件
上述步骤描述了如何使用 C# 更改 PDF 查看首选项。将源 PDF 文件加载到包含属性的 Document 类对象中以更改打开设置。更改属性后,根据需要将输出文件保存到磁盘或流中。
使用 C# 更改设置以打开 PDF 文件的代码
using Aspose.Pdf; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
new License().SetLicense("License.lic"); | |
// Open document | |
Document pdfDocument = new Document("sample.pdf"); | |
pdfDocument.CenterWindow = true; | |
pdfDocument.Direction = Direction.R2L; | |
pdfDocument.DisplayDocTitle = true; | |
pdfDocument.FitWindow = true; | |
pdfDocument.HideMenubar = true; | |
pdfDocument.HideToolBar = true; | |
pdfDocument.HideWindowUI = true; | |
pdfDocument.NonFullScreenPageMode = PageMode.UseOC; | |
pdfDocument.PageLayout = PageLayout.TwoColumnLeft; | |
pdfDocument.PageMode = PageMode.UseThumbs; | |
pdfDocument.Save("output.pdf"); | |
} | |
} |
此示例代码演示了使用 C# 更改如何打开 PDF 的过程。我们设置了各种属性,例如方向(可以是 R2L 或 L2R)、设置退出全屏模式时的页面模式、设置页面布局和其他 UI 设置。CenterWindow 的默认值为 false,方向为 L2R,在标题栏中显示 PDF 文件名的标志为 false,隐藏菜单栏的标志为 false。
本快速教程可帮助您使用 C# 更改打开 PDF 设置。要更改 PDF 文件的密码,请参阅 如何使用 C# 更改 PDF 密码 上的文章。