From e7cec66e6cd3975fdae7a8f36af59f4f56e67fc0 Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Wed, 31 Jul 2024 16:02:34 -0400 Subject: [PATCH] Added a different example to the scratch file. --- scratch.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/scratch.cs b/scratch.cs index e0d3df7..6666fd8 100644 --- a/scratch.cs +++ b/scratch.cs @@ -26,3 +26,38 @@ class Program } } } +using System; +using System.IO; +using System.Linq; +using QuestPDF.Fluent; +using QuestPDF.Infrastructure; + +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); + } +}