没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
翻译|行业资讯|编辑:胡涛|2024-04-15 13:31:47.297|阅读 76 次
概述:在本文中,您将学习如何使用Spire.PDF for .NET将多个 PDF 文档合并为一个 PDF 文档,以及如何使用C# 和 VB.NET将不同 PDF 文档中的选定页面合并为一个 PDF 。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
需要合并 PDF 的原因有很多。例如,合并 PDF 文件允许您打印单个文件,而不是为打印机排队多个文档,组合相关文件通过减少要搜索和组织的文件数量来简化管理和存储多个文档的过程。在本文中,您将学习如何使用Spire.PDF for .NET将多个 PDF 文档合并为一个 PDF 文档,以及如何使用C# 和 VB.NET将不同 PDF 文档中的选定页面合并为一个 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 java下载
首先,您需要将 Spire.PDF for .NET 包中包含的 DLL 文件添加为 .NET 项目中的引用。 DLL 文件可以从此链接下载或通过NuGet安装。
PM> Install-Package Spire.PDF
Spire.PDF for .NET 提供PdfDocument.MergeFiles()方法将多个 PDF 文档合并为单个文档。详细步骤如下。
C#
using System; using Spire.Pdf; namespace MergePDFs { class Program { static void Main(string[] args) { //Get the paths of the documents to be merged String[] files = new String[] { "C:\\Users\\Administrator\\Desktop\\PDFs\\sample-1.pdf", "C:\\Users\\Administrator\\Desktop\\PDFs\\sample-2.pdf", "C:\\Users\\Administrator\\Desktop\\PDFs\\sample-3.pdf"}; //Merge these documents and return an object of PdfDocumentBase PdfDocumentBase doc = PdfDocument.MergeFiles(files); //Save the result to a PDF file doc.Save("output.pdf", FileFormat.PDF); } } }
VB.NET
Imports System Imports Spire.Pdf Namespace MergePDFs Class Program Shared Sub Main(ByVal args() As String) 'Get the paths of the documents to be merged Dim files() As String = New String() {"C:\\Users\\Administrator\\Desktop\\PDFs\\sample-1.pdf","C:\\Users\\Administrator\\Desktop\\PDFs\\sample-2.pdf","C:\\Users\\Administrator\\Desktop\\PDFs\\sample-3.pdf"} 'Merge these documents and return an object of PdfDocumentBase Dim doc As PdfDocumentBase = PdfDocument.MergeFiles(files) 'Save the result to a PDF file doc.Save("output.pdf", FileFormat.PDF) End Sub End Class End Namespace
Spire.PDF for .NET 提供PdfDocument.InsertPage()方法和PdfDocument.InsertPageRange()方法,用于将页面或页面范围从一个 PDF 文档导入到另一个 PDF 文档。以下是将不同 PDF 文档中的选定页面合并为一个新 PDF 文档的步骤。
C#
using System; using Spire.Pdf; namespace MergeSelectedPages { class Program { static void Main(string[] args) { //Get the paths of the documents to be merged String[] files = new String[] { "C:\\Users\\Administrator\\Desktop\\PDFs\\sample-1.pdf", "C:\\Users\\Administrator\\Desktop\\PDFs\\sample-2.pdf", "C:\\Users\\Administrator\\Desktop\\PDFs\\sample-3.pdf"}; //Create an array of PdfDocument PdfDocument[] docs = new PdfDocument[files.Length]; //Loop through the documents for (int i = 0; i < files.Length; i++) { //Load a specific document docs[i] = new PdfDocument(files[i]); } //Create a PdfDocument object for generating a new PDF document PdfDocument doc = new PdfDocument(); //Insert the selected pages from different documents to the new document doc.InsertPage(docs[0], 0); doc.InsertPageRange(docs[1], 1,3); doc.InsertPage(docs[2], 0); //Save the document to a PDF file doc.SaveToFile("output.pdf"); } } }
VB.NET
Imports System
Imports Spire.Pdf
Namespace MergeSelectedPages
Class Program
Shared Sub Main(ByVal args() As String)
'Get the paths of the documents to be merged
Dim files() As String = New String() {"C:\\Users\\Administrator\\Desktop\\PDFs\\sample-1.pdf","C:\\Users\\Administrator\\Desktop\\PDFs\\sample-2.pdf","C:\\Users\\Administrator\\Desktop\\PDFs\\sample-3.pdf"}
'Create an array of PdfDocument
Dim docs() As PdfDocument = New PdfDocument(files.Length) {}
'Loop through the documents
Dim i As Integer
For i = 0 To files.Length- 1 Step i + 1
'Load a specific document
docs(i) = New PdfDocument(files(i))
Next
'Create a PdfDocument object for generating a new PDF document
Dim doc As PdfDocument = New PdfDocument()
'Insert the selected pages from different documents to the new document
doc.InsertPage(docs(0), 0)
doc.InsertPageRange(docs(1), 1,3)
doc.InsertPage(docs(2), 0)
'Save the document to a PDF file
doc.SaveToFile("output.pdf")
End Sub
End Class
End Namespace
以上便是如何合并 PDF文件,如果您有其他问题也可以继续浏览本系列文章,获取相关教程,你还可以给我留言或者加入我们的官方技术交流群。
欢迎下载|体验更多E-iceblue产品
获取更多信息请咨询慧都在线客服 ;技术交流Q群(767755948)
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com
Java 开发团队常常面临测试覆盖率与开发效率的双重挑战。通过引入 AI 与自动化工具,团队不仅能减轻静态分析与单元测试的负担,还能在保障代码质量的同时提升开发节奏。本文以 Parasoft Jtest 为案例,深入探讨了当前主流的 AI 测试实践如何帮助企业实现代码级测试的优化与落地。
Sparx Systems Enterprise Architect(EA)作为一款领先的企业级建模工具,凭借其强大的四大引擎——BPSim、DMN、Open Modelica/SysML和可执行代码生成,为企业提供了从流程优化到智能决策的全方位支持。本文将深入解析这四大核心引擎如何显著提升企业建模的智能化水平和实用价值。
UI自动化测试中,团队常因语言偏好不同而协作困难,脚本复用也麻烦。从简单的录制测试升级到灵活脚本,或者搭建稳定框架,往往费时费力。TestComplete用自动化UI测试直接解决这些问题:它支持多种语言并行开发(Python, C#, C++等),让每个人用顺手的工具;还能轻松把录制脚本转换成代码,省去重写麻烦;并且自带实用框架和项目示例,开箱即用,大大加快搭建速度。
CodeRush 25.1 新推 AI 双引擎 AiGen(语音/文字生成与修改代码)和 AiFind(智能代码搜索),直接在 Visual Studio 环境中响应,免除窗口切换与手动操作,让开发者更专注核心问题。
Spire.PDF for .NET是独立的PDF控件,用于.NET程序中创建、编辑和操作PDF文档
Spire.PDF for WPFSpire.PDF for WPF 是一款让你的app能够读取、写入和操作PDF文档的完全独立的组件,不需要任何第三方组件库。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@evget.com
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
慧都科技 版权所有 Copyright 2003-
2025 渝ICP备12000582号-13 渝公网安备
50010702500608号