Change color of LineAnnotation or PolyAnnotation

Hi,
I’m unable to change the color of an existing lineannotation (or polyannotation) to another value depending on some businesslogic.
I use at the moment following method call:
if (somevalue == 0)
lineAnn.Color = Aspose.Pdf.Color.Green;

The annotation (which is a measurement) has originally the color red, but I want to set it to another color. It doesn’t work by simply changing the color property. Or do I need to something else ?

TIA,
Mark

@MarkBrouwers

Could you please share you sample PDF document for our reference so that we can test the scenario in our environment and address it accordingly.

Hi Ali,
Here’s a sample of a PDF (with 2 poly annotations : a red one and a green one). I want to be able to change the color of those poly annotations into something else via the API.

Sample_Aspose_ChangeColor_PolyAnnotation.pdf (1.67 MB)

@MarkBrouwers

We are checking it and will get back to you shortly.

@MarkBrouwers

We tried to change the color of the annotations using below code snippet and Aspose.PDF for .NET 22.7 but were unable to achieve correct results:

Document pdfDocument = new Document(dataDir + "Sample_Aspose_ChangeColor_PolyAnnotation.pdf");
foreach (Annotation annotation in pdfDocument.Pages[1].Annotations)
{
 if (annotation is PolyAnnotation)
 {
  annotation.Color = Aspose.Pdf.Color.Magenta;
  PolyAnnotation line = (PolyAnnotation)annotation;
  line.InteriorColor = Color.Magenta;
  line.Characteristics.Background = System.Drawing.Color.Magenta;
 }
 if(annotation is LineAnnotation)
 {
  annotation.Color = Aspose.Pdf.Color.Yellow;
  LineAnnotation line = (LineAnnotation)annotation;
  line.InteriorColor = Color.Yellow;
  line.Characteristics.Background = System.Drawing.Color.Yellow;
 }
}
pdfDocument.Save(dataDir + "result.pdf");

Hence, an issue as PDFNET-52216 has been logged in our issue tracking system. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.