当前位置:网站首页>C#/VB. Net merge PDF document
C#/VB. Net merge PDF document
2022-07-01 15:57:00 【InfoQ】
Will be multiple PDF Merge into one PDF file
- Get the paths of the documents to be merged and store them in a string array .
- call PdfDocument.MergeFiles() Method to merge documents .
- use PdfDocumentBase.Save() Method is saved as a PDF file
using System;
using Spire.Pdf;
namespace MergePDFs
{
class Program
{
static void Main(string[] args)
{
// Get the path of the document to be merged
String[] files = new String[] {
"Sample.pdf",
"Sample1.pdf",
"Samplex.pdf"
// Merge documents
PdfDocumentBase doc = PdfDocument.MergeFiles(files);
// Save the results to PDF file
doc.Save("MergeDocuments.pdf", FileFormat.PDF);
}
}
}Imports System
Imports Spire.Pdf
Namespace MergePDFs
Class Program
Private Shared Sub Main(ByVal args() As String)
' Get the path of the document to be merged
Dim files() As String = New String() {" Sample.pdf", "Sample-1.pdf", "Samplex.pdf"}
' Merge documents
Dim doc As PdfDocumentBase = PdfDocument.MergeFiles(files)
' Save the results to PDF file
doc.Save("output.pdf", FileFormat.PDF)
End Sub
End Class
End Namespace
Will be different PDF The specified pages of are merged into one PDF file
- Get the path of the source document and store them in the string array .
- Create a PdfDocument Array , And load each source document into a separate PdfDocument object .
- Use PdfDocument.InsertPage() Methods and PdfDocument.InsertPageRange() Method to insert the specified page of the source document into the new document .
- use PdfDocument.SaveToFile() Method to save the new document as PDF.
using System;
using Spire.Pdf;
namespace MergeSelectedPages
{
class Program
{
static void Main(string[] args)
{
// Get the path of the document to be merged
String[] files = new String[] {
"Sample1.pdf",
"Sample.pdf",
"Sample2.pdf"};
// Create a PdfDocument Array
PdfDocument[] docs = new PdfDocument[files.Length];
// Cycle through documents
for (int i = 0; i < files.Length; i++)
{
// Load the specified document
docs[i] = new PdfDocument(files[i]);
}
// Create a PdfDocument Object to generate a new PDF file
PdfDocument doc = new PdfDocument();
// Insert the specified pages in different documents into the new document
doc.InsertPage(docs[0], 0);
doc.InsertPageRange(docs[1], 0, 2);
doc.InsertPage(docs[2], 1);
// Save the document as PDF file
doc.SaveToFile("output.pdf");
}
}
}Imports System
Imports Spire.Pdf
Namespace MergeSelectedPages
Class Program
Private Shared Sub Main(ByVal args() As String)
' Get the path of the document to be merged
Dim files() As String = New String() {"Sample1.pdf", "Sample.pdf", "Sample2.pdf"}
' Create a PdfDocument Array
Dim docs() As PdfDocument = New PdfDocument((files.Length) - 1) {}
' Cycle through documents
Dim i As Integer = 0
Do While (i < files.Length)
' Load the specified document
docs(i) = New PdfDocument(files(i))
i = (i + 1)
Loop
' Create a PdfDocument Object to generate a new PDF file
Dim doc As PdfDocument = New PdfDocument
' Insert the specified pages in different documents into the new document
doc.InsertPage(docs(0), 0)
doc.InsertPageRange(docs(1), 0, 2)
doc.InsertPage(docs(2), 1)
' Save the document as PDF file
doc.SaveToFile("output.pdf")
End Sub
End Class
End Namespace
边栏推荐
- process. env. NODE_ ENV
- 【php毕业设计】基于php+mysql+apache的教材管理系统设计与实现(毕业论文+程序源码)——教材管理系统
- Task. Run(), Task. Factory. Analysis of behavior inconsistency between startnew() and new task()
- Pocket Network为Moonbeam和Moonriver RPC层提供支持
- Seata中1.5.1 是否支持mysql8?
- Stm32f4-tft-spi timing logic analyzer commissioning record
- Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知
- ThinkPHP kernel work order system source code commercial open source version multi user + multi customer service + SMS + email notification
- 新出生的机器狗,打滚1小时后自己掌握走路,吴恩达开山大弟子最新成果
- 2022-07-01日报:谷歌新研究:Minerva,用语言模型解决定量推理问题
猜你喜欢

【开源数据】基于虚拟现实场景的跨模态(磁共振、脑磁图、眼动)人类空间记忆研究开源数据集

自動、智能、可視!深信服SSLO方案背後的八大設計

#夏日挑战赛# HarmonyOS canvas实现时钟

ATSS:自动选择样本,消除Anchor based和Anchor free物体检测方法之间的差别

Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results

基于PHP的轻量企业销售管理系统

【OpenCV 例程200篇】216. 绘制多段线和多边形

6.2 normalization 6.2.6 BC normal form (BCNF) 6.2.9 normalization summary

STM32F1与STM32CubeIDE编程实例-PWM驱动蜂鸣器生产旋律

TensorFlow团队:我们没被抛弃
随机推荐
如何写出好代码 - 防御式编程指南
Go语学习笔记 - gorm使用 - 表增删改查 | Web框架Gin(八)
MySQL的零拷贝技术
Smart Party Building: faith through time and space | 7.1 dedication
Redis high availability principle
How to adjust the size of computer photos to what you want
[PHP graduation design] design and implementation of textbook management system based on php+mysql+apache (graduation thesis + program source code) -- textbook management system
Comment win11 définit - il les permissions de l'utilisateur? Win11 comment définir les permissions de l'utilisateur
[200 opencv routines] 216 Draw polylines and polygons
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
AVL balanced binary search tree
VIM from dislike to dependence (22) -- automatic completion
Nuxt. JS data prefetching
Can't global transactions be used when shardingjdbc is used in seate?
Does 1.5.1 in Seata support mysql8?
Pico,是要拯救还是带偏消费级VR?
Win11如何設置用戶權限?Win11設置用戶權限的方法
2022-07-01日报:谷歌新研究:Minerva,用语言模型解决定量推理问题
周少剑,很少见
Hardware development notes (9): basic process of hardware development, making a USB to RS232 module (8): create asm1117-3.3v package library and associate principle graphic devices