Spire.PDF for .NET【页面设置】演示:重新排列 PDF 中的页面

对于页面顺序混乱的 PDF 文档,重新排列页面可以避免读者感到困惑,还可以使文档更有条理。本文将演示如何使用Spire.PDF for .NET以编程方式重新排列现有 PDF 文档中的页面。

Spire.PDF for .NET 是一款独立 PDF 控件,用于 .NET 程序中创建、编辑和操作 PDF 文档。使用 Spire.PDF 类库,开发人员可以新建一个 PDF 文档或者对现有的 PDF 文档进行处理,且无需安装 Adobe Acrobat。

E-iceblue功能类库Spire 系列文档处理组件均由中国本土团队研发,不依赖第三方软件,不受其他国家的技术或法律法规限制,同时适配国产操作系统如中科方德、中标麒麟等,兼容国产文档处理软件 WPS(如 .wps/.et/.dps 等格式

Spire.PDF for.net下载

安装 Spire.PDF for .NET

首先,您需要将 Spire.PDF for.NET 包中包含的 DLL 文件作为引用添加到您的 .NET 项目中。可以从此链接下载 DLL 文件,也可以通过NuGet安装。

复制代码
PM> Install-Package Spire.PDF

重新排列现有 PDF 文档中的页面

  • 创建一个PdfDocument对象。
  • **使用PdfDocument.LoadFromFile()**方法加载示例 PDF 文档。
  • 使用PdfDocument.Pages属性获取 PDF 文档中的页面。
  • 使用**PdfPageCollection.ReArrange **(int[] orderArray)****方法重新排列 PDF 页面。
  • **使用PdfDocument.SaveToFile()**方法将文档保存到另一个文件。

【C#】

复制代码
using Spire.Pdf;

namespace RearrangePDF
{
class Program
{
static void Main(string[] args)
{
//Create a PdfDocument object
PdfDocument pdf = new PdfDocument();

//Load a sample PDF document
pdf.LoadFromFile("input.pdf");

//Rearrange pages by page index
pdf.Pages.ReArrange(new int[] { 1, 0, 2, 3 });

//Save the document
pdf.SaveToFile("ChangeOrder.pdf");
pdf.Close();
}
}
}

VB.NET

复制代码
using Spire.Pdf;

namespace RearrangePDF
{
class Program
{
static void Main(string[] args)
{
//Create a PdfDocument object
PdfDocument pdf = new PdfDocument();

//Load a sample PDF document
pdf.LoadFromFile("input.pdf");

//Rearrange pages by page index
pdf.Pages.ReArrange(new int[] { 1, 0, 2, 3 });

//Save the document
pdf.SaveToFile("ChangeOrder.pdf");
pdf.Close();
}
}
}
相关推荐
hrrrrb1 天前
【Spring Security】Spring Security 概念
java·数据库·spring
小信丶1 天前
Spring 中解决 “Could not autowire. There is more than one bean of type“ 错误
java·spring
周杰伦_Jay1 天前
【Java虚拟机(JVM)全面解析】从原理到面试实战、JVM故障处理、类加载、内存区域、垃圾回收
java·jvm
程序员小凯1 天前
Spring Boot测试框架详解
java·spring boot·后端
豐儀麟阁贵1 天前
基本数据类型
java·算法
_extraordinary_1 天前
Java SpringMVC(二) --- 响应,综合性练习
java·开发语言
CsharpDev-奶豆哥1 天前
ASP.NET中for和foreach使用指南
windows·microsoft·c#·asp.net·.net
程序员 Harry1 天前
深度解析:使用ZIP流式读取大型PPTX文件的最佳实践
java
wxweven1 天前
校招面试官揭秘:我们到底在寻找什么样的技术人才?
java·面试·校招
陈陈爱java1 天前
新知识点背诵
java