I am working on a project where I am taking a single PDF file, reading the text on each page, adding bookmarks to it, and outputting it into a different folder. I have done this with version 8.x of the Merger with no issues. We recently upgraded to version 9.x (specifically v9.0.0.40 Build 36008) and now when I am calling the GetText() method on the pages I am getting a System.FormatException: Header checksum illegal error. Below is the code I am using:
// Activates our license
RegisterDynamicPdf();
string sourcePdf = @"C:\temp\UnprocessedPdfs\singlePageTest.pdf";
string destinationPdf = @"C:\temp\ProcessedPdfs\singlePageTest.pdf";
PdfDocument doc = new PdfDocument(sourcePdf);
MergeDocument writer;
MergeOptions options = MergeOptions.None;
Outline parentOutline = null;
Outline childOutline;
Regex regex = new Regex(@"\|.+\|");
writer = new MergeDocument(doc, options);
for (int i = 0; i < doc.Pages.Count; i++)
{
try
{
pageText = doc.Pages[i].GetText(); <-- This is throwing the exception
}
catch(NullReferenceException nrex)
{
// Pages with no text throw this exception. Ignore it
pageText = "";
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
}
// The remainder of the code is for adding the bookmarks in the appropriate place
}
I'm using text on the page to determine what needs to go in the bookmark.