I've just downloaded the Free Spire.PDF Package form NuGet Package manger and tried to merge 2 Documents. But for some reason it doesn't work. It does create the new document but the document isn't added. It's also confusing that the line
- Code: Select all
PdfDocument EmptyPageDoc = new PdfDocument(EmptyPagePath);
Here's the code:
- Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Spire.Pdf;
namespace Numberizer
{
class Program
{
const string EmptyPagePath = @"C:\Users\mr\Desktop\Empty.pdf";
static void Main(string[] args)
{
PdfDocument EmptyPageDoc = new PdfDocument();
PdfDocument ScannedDoc = new PdfDocument();
EmptyPageDoc.LoadFromFile(EmptyPagePath);
ScannedDoc.LoadFromFile(args[0]);
ScannedDoc.AppendPage(EmptyPageDoc);
ScannedDoc.InsertPage(EmptyPageDoc, 0);
try
{
ScannedDoc.SaveToFile(@"H:\Documents\Scanned\Dokument_neu.pdf");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
string inp = Console.ReadLine();
}
ScannedDoc.Close();
EmptyPageDoc.Close();
}
}
}
thank you for your help.