Saving the color of an annotation in pdftron (pdfnet winforms)
<p>I'm trying to reuse the color of a highlight annotation after a pdf document and it's highlights have been saved.</p>

<p>I add an annotation and assign a color this way:</p>

<pre><code>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();
</code></pre>

<p>markingscolors is a dictionary with colors that i add in the constructor:</p>

<pre><code>   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));
</code></pre>

<p>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.</p>

<p>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):</p>

<pre><code> 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;
    }
</code></pre>

<p>I call it this way:</p>

<pre><code> foreach (MarkingColor color in colors)
                    {
                        if (ColorsEqual(annotation.GetColorAsRGB(), markingColors[color]))
                        {
                            int indentation = indentations[color];
                            for (int j = 1; j &lt;= indentation; j++)
                            {
                                text += " ";
                            }
                            text += annotation.GetContents();
                            break;
                        }
                    }
</code></pre>

<p>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</p>

<p>How can this be solved?</p>