I am getting a problem when merging two files. If I try to have the AddPage(from.Pages[i]);
in a separate void function I get
An object reference is required for the non-static field, method, or property It relates to
CopyPages(one, outPdf); CopyPages(two, outPdf);
If I make it a static void it will run but the console displays an error stating that it "can not save a PDF with no pages"
static void Main(string[] args)
{
PdfDocument one = new PdfDocument("1.pdf");
PdfDocument two = new PdfDocument("2.pdf");
PdfDocument outPdf = new PdfDocument();
{
CopyPages(one, outPdf);
CopyPages(two, outPdf);
outPdf.Save(out.pdf);
}
}
void CopyPages(PdfDocument from, PdfDocument to)
{
for (int i = 0; i < from.PageCount; i++)
{
to.AddPage(from.Pages[i]);
}
}