I'm trying to reuse the color of a highlight annotation after a pdf document and it's highlights have been saved.
I add an annotation and assign a color this way:
if (isCustomColor)
{
ColorPt color = markingColors[m_editColor];
hightlightAnnot.SetColor(color,3);
hightlightAnnot.RefreshAppearance();
}
pdftron.PDF.Page page = doc.GetPage(selectionPageNum);
TextExtractor txtExtractor = new TextExtractor();
txtExtractor.Begin(page, hightlightAnnot.GetRect());
hightlightAnnot.SetContents(txtExtractor.GetAsText());
doc.Lock();
page.AnnotPushBack(hightlightAnnot);
doc.Unlock();
markingscolors is a dictionary with colors that i add in the constructor:
markingColors.Add(MarkingColor.black, new ColorPt(113 / 255.0, 113 / 255.0, 113 / 255.0));
markingColors.Add(MarkingColor.yellow, new ColorPt(1, 1, 0));
markingColors.Add(MarkingColor.red, new ColorPt(1, 0, 0));
markingColors.Add(MarkingColor.green, new ColorPt(0, 1, 0));
markingColors.Add(MarkingColor.blue, new ColorPt(45/255.0, 126/255.0, 205/255.0));
The problem is that i can't retrieve the color of an annotation if it has been set to black or blue (double type values) after saving and reopening the pdf.
to check if colors are equal (to get highlights with a specific color for exporting them to an rtf document and adding indentations based on the colors in the rtf document):
private bool ColorsEqual(ColorPt color1, ColorPt color2)
{
if (color1.Get(0) != color2.Get(0))
{
return false;
}
if (color1.Get(1) != color2.Get(1))
{
return false;
}
if (color1.Get(2) != color2.Get(2))
{
return false;
}
return true;
}
I call it this way:
foreach (MarkingColor color in colors)
{
if (ColorsEqual(annotation.GetColorAsRGB(), markingColors[color]))
{
int indentation = indentations[color];
for (int j = 1; j <= indentation; j++)
{
text += " ";
}
text += annotation.GetContents();
break;
}
}
but the color of the annotation always returns an integer value instead of a double, that's why black and blue aren't working... Also if the extraction is done immediatly instead of reopening the pdf, there's no problem and the colors are working perfectly
How can this be solved?