We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error during adding line to PDF document


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.”


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++)

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 };


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

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


Thank you,


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.


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.