We have encountered with exception during merging process of a file with Section Breaks.
Steps to reproduce :
- Create Word document with Section Breaks
Section Break can be the last element of the document or the single element on the page (see our attachments with 2 examples).
- Try to merge some file with this Word document with Section Breaks with the following flow:
- Convert the Word document with Section Breaks to PDF with exporting structure (i.e use PDF/A-1a standard)
- Merge the documents in turn:
- Some other document
- Word document with Section Breaks is converted to PDF
Required condition – Copying of logical structure is enabled (
PdfFileEditor.CopyLogicalStructure = true).
Exception is thrown:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at Aspose.Pdf.Facades.PdfFileEditor.#=zmM$J8H4=(Exception #=z_XQGF4o=)
at Aspose.Pdf.Facades.PdfFileEditor.Concatenate(String inputFiles, String outputFile)
at DCError.Program.Merge(String firstFile, String secondFile) in C:\Users\alexander.zolotarev\source\repos\DCError\DCError\Program 228652.cs:line 62
at DCError.Program.Main() in C:\Users\alexander.zolotarev\source\repos\DCError\DCError\Program 228652.cs:line 39
Merge is completed
Logical structure of the all input documents is copied
- 1.docx - first file example
- 2.docx - second file example
- Program.cs – example of the code for conversion and merging (we also added the example for merging the same file is converted via MS Word)
content.zip (204.7 KB)
Aspose libraries that we use:
- Aspose.Word v. 126.96.36.199
- Aspose.Pdf v. 188.8.131.52
But with the newest ones it is reproducible anyway:
- Aspose.Word v. 184.108.40.206
- Aspose.Pdf v. 220.127.116.11
We have noticed that the conversion of the Word document with Section break to PDF leads to creation one extra empty page(we already reported this issue - Extra Page is Created when Document with Section Breaks (Odd Page) is Save to PDF using .NET ). The same behavior has conversion of Word document to PDF via MS Word. But file is got via MS Word can be merged successfully.
Could you please advise us with the current behavior?