Error during adding line to PDF document

Hi,

I’m trying to add a line to the PDF document and I get the error “An item with the same key has already been added.”

--------------Code-----------------

Document asposePDFDoc = new Document(Path.Combine(targetLocation, rptOutputName));

Point startH = new Point(72, 749);
Point endH = new Point(542, 749);
Aspose.Pdf.Annotations.LineAnnotation AsposeLineAnnH = new Aspose.Pdf.Annotations.LineAnnotation(asposePDFDoc, startH, endH);

Point startF = new Point(72, 44);
Point endF = new Point(542, 44);
Aspose.Pdf.Annotations.LineAnnotation AsposeLineAnnF = new Aspose.Pdf.Annotations.LineAnnotation(asposePDFDoc, startF, endF);


for (int i = 1; i < asposePDFDoc.Pages.Count; i++)
{
	asposePDFDoc.Pages[i].Annotations.Add(AsposeLineAnnH);
	asposePDFDoc.Pages[i].Annotations.Add(AsposeLineAnnF);
}

AsposeLineAnnH.Color = Aspose.Pdf.Color.Black;
AsposeLineAnnH.Border = new Aspose.Pdf.Annotations.Border(AsposeLineAnnH) { Width = 1 };

AsposeLineAnnF.Color = Aspose.Pdf.Color.Black;
AsposeLineAnnF.Border = new Aspose.Pdf.Annotations.Border(AsposeLineAnnF) { Width = 1 };

asposePDFDoc.Flatten();

//File.Delete(Path.Combine(targetLocation, rptOutputName));

asposePDFDoc.Save(Path.Combine(targetLocation, "Final_" + rptOutputName)); //ERROR AT THIS LINE

asposePDFDoc.Dispose();

Thank you,
Shankar

@naru.shiva

Thank you for contacting support.

Would you please share the source PDF file with us so that we may try to reproduce and investigate it further. Before sharing requested data, please ensure using Aspose.PDF for .NET 18.8 in your environment.

@naru.shiva

Thank you for sharing requested data.

We have worked with the data shared by you and have been able to reproduce ArgumentException in our environment. A ticket with ID PDFNET-45251 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFNET-45251) have been fixed in Aspose.PDF for .NET 23.4.