64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using QuestPDF.Fluent;
|
|
using QuestPDF.Infrastructure;
|
|
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
internal class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
// Create a new PDF document
|
|
using (var stream = new MemoryStream())
|
|
{
|
|
var document = new Document(stream);
|
|
|
|
// Add each PDF document to the output document
|
|
for (int i = 1; i < args.Length; i++)
|
|
{
|
|
var inputDocument = new Document(new FileStream(args[i], FileMode.Open));
|
|
document.Append(inputDocument.GetContent());
|
|
}
|
|
|
|
// Save the output document
|
|
document.Save();
|
|
File.WriteAllBytes("merged.pdf", stream.ToArray());
|
|
}
|
|
}
|
|
}
|
|
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using QuestPDF.Fluent;
|
|
using QuestPDF.Infrastructure;
|
|
|
|
internal class Program
|
|
{
|
|
static void MergePdfFiles(string[] filePaths, string outputPath)
|
|
{
|
|
// Create a new PDF document
|
|
using (var stream = new MemoryStream())
|
|
{
|
|
var document = new Document(stream);
|
|
|
|
// Add each PDF document to the output document
|
|
for (int i = 0; i < filePaths.Length; i++)
|
|
{
|
|
var inputDocument = new Document(new FileStream(filePaths[i], FileMode.Open));
|
|
document.Append(inputDocument.GetContent());
|
|
}
|
|
|
|
// Save the output document
|
|
document.Save();
|
|
File.WriteAllBytes(outputPath, stream.ToArray());
|
|
}
|
|
}
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
string[] filePaths = { "input1.pdf", "input2.pdf", "input3.pdf" };
|
|
string outputPath = "merged.pdf";
|
|
MergePdfFiles(filePaths, outputPath);
|
|
}
|
|
}
|