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