ArgumentOutOfRangeException when using pdfFileEditor.Concatenate on specific PDF Files

Hi!

We are receiving an ArgumentOutOfRangeException when using pdfFileEditor.Concatenate on specific PDF Files. Trying to combine the same PDF Files in Adobe works without a Problem, so the PDF Files do not seem to be completely broken.

Tested on the latest Aspose.Net Package (I tested with NuGet Gallery | Aspose.PDF 23.10.0 Version 22.7.0)

Files to Reproduce:

Code to Reproduce:

  //Exception either order
  var file1 = @"FaultyFile1.pdf";
  var file2 = @"FaultyFile2.pdf";

  //No Exception when order is changed
  //var file1 = @"FaultyFile2.pdf";
  //var file2 = @"OtherFile.pdf";

  //No Exception when order is changed
  //var file1 = @"FaultyFile1.pdf";
  //var file2 = @"OtherFile.pdf";


  var document1 = new Document(file1);
  var document2 = new Document(file2);

  var pdfFileEditor = new PdfFileEditor
  {
    AllowConcatenateExceptions = true,
    CopyLogicalStructure = true,
    CopyOutlines = true,
    KeepFieldsUnique = true,
    MergeDuplicateOutlines = true,
    OptimizeSize = false,
    IncrementalUpdates = true,
  };

  pdfFileEditor.Concatenate(new []{ document1 }, document2);

Notes for the Reproduction:

  • The Problem occurred when we tried to concatenate a bunch of PDF Files. This is a condensed sample, with only the relevant pieces extracted
  • The error seems to happen with the FaultyFiles. However, i can also only reproduce it with “OtherFile”. When i generate a fresh PDF File with Adobe, the concatenating with the FaultyFiles work. However, “OtherFile” concatenates without Problems with other PDF Files, so i feel that the Problem is mainly with the FaultyFiles
  • If the order, in which the files are concatenated are changed, there is different behaviour. With the two FaultyFiles, the behaviour does not change. When concatenating it with “OtherFile” however, changing the order results in no Exception

Is this something that can be changed in Aspose, or is there a problem with the PDF Files?

Thank you very much!

Best Regards,
Florian

@florian.decker

We have logged this problem in our issue tracking system as PDFNET-52181. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.