Overlapping highlights of the same color results in dark overlap...needs all the same color !

Hi,

Let’s say I have two highlights that are blue, and where they overlaps results in dark blue. I need it all to be the same color of blue (the same color as each individual highlight).

…Or in other words, hide the fact that they are overlapping.

Please advise and thanks,

Barry

Is this for PDFViewWPF? By default this is not the behavior, highlighting with the same color over and over again should not affect the appearance.

This is accomplished by using the Multiply Blend Mode. Other blend modes, such as Normal, would result in the behavior you see.

If you are doing custom highlight appearance, try switching the blend mode to multiple.

Yes, I’m using PDFViewWPF…

The issue is that we implement some functionality to merge highlights when they overlap. A merged highlight is a collective of all the Rects between what was merged, and they all need to be the same colour.

I’ll see if I can find the blend mode option…thanks…if you have a line of code to share, feel free.

Thanks,

Barry

The way I was creating the highlight was as follows:

Rect highlightRect = new Rect(decodedX1, decodedY1, decodedX2, decodedY2);

pdftron.PDF.Annots.Highlight highlight = pdftron.PDF.Annots.Highlight.Create(_pdfDocument.GetSDFDoc(), highlightRect);
highlight.SetQuadPoint(0, new QuadPoint(new Point(highlightRect.x1, highlightRect.y2), new Point(highlightRect.x2, highlightRect.y2), new Point(highlightRect.x2, highlightRect.y1), new Point(highlightRect.x1, highlightRect.y1)));

colour = _iPdf.Highlights.DefaultHighlightColor; //custom color

//This sets the opacity for the annotations color (0.2 is what we use)
pdftron.PDF.Annots.Markup markup = new pdftron.PDF.Annots.Markup(highlight);
markup.SetOpacity(0.2);

pdftron.PDF.Page page = _pdfDocument.GetPage(int.Parse(annotationLocation.Page.ToString()));

page.AnnotPushBack(highlight);

…this resulted in overlapping highlights with darker colors at the points of overlap.

I tried switching to doing it like this: http://www.pdftron.com/pdfnet/samplecode/data/HighlightPDFText.cs
…there alot more code involved, but it does give me the opportunity to incorporate e_bl_multiply, however using that with an opacity factor to dial down the colors a bit (gs.SetFillOpacity(0.2); ) resulted in the text being darker again on the overlaps. If I didn’t use an opactity it all looked the same, but for cross-platform reasons (and business rules given to me) the opactity has to be set.

I’ll keep tinkering, but if you have any suggestions, please feel free…

Barry

I altered my code to merged the rects that overlap, and then delete the ones involved in the merge…thus there is no overlap left to result in a darker colour.

IntersectRect() is a wonderful thing !

Thanks,

Barry

Great, thanks for letting us know about the trick.