private static Highlight setHighlight(BaseAnnotation xhl) //I need it to work for both Area and Text Highlights { pdftron.PDF.Rect r = AnnotationsMannager.ConvertRect(xhl.RectArea()); Highlight hl = Highlight.Create(_currentDoc, r); return(hl); }
public static Annot CreatePDFAnnotation(BaseAnnotation annotation, PDFDoc pdfDocument, bool fromViewer) { _currentDoc = pdfDocument; Annot pdfAnnotation; switch (annotation.Properties.PropertyName) { case XMLHighlightText.Names.Highlight: case XMLHighlightArea.Names.Highlight: pdfAnnotation = setHighlight(annotation); break; case StickyNote.Names.StickyNote: pdfAnnotation = setStickyNote((StickyNote)annotation, fromViewer); break; case MarkArea.Names.MarkArea: pdfAnnotation = setMarkArea((MarkArea)annotation); break; case FreeText.Names.FreeText: pdfAnnotation = setFreeText((FreeText)annotation, fromViewer); break; case Circle.Names.Circle: pdfAnnotation = setCircle((Circle)annotation); break; case Square.Names.Square: pdfAnnotation = setSquare((Square)annotation); break; case Line.Names.Line: pdfAnnotation = setLine((Line)annotation); break; case StamperImage.Names.Stamper: pdfAnnotation = setStamperImage((StamperImage)annotation); break; case StamperText.Names.Stamper: pdfAnnotation = setStamperText((StamperText)annotation); break; case RubberStamp.Names.RubberStamp: pdfAnnotation = setRubberStamp((RubberStamp)annotation); break; case XMLSquiggly.Names.Squiggly: pdfAnnotation = setSquiggly((XMLSquiggly)annotation); break; case XMLStrikeout.Names.Strikeout: pdfAnnotation = setStrikeout((XMLStrikeout)annotation); break; case XMLUnderline.Names.Underline: pdfAnnotation = setUnderline((XMLUnderline)annotation); break; default: pdfAnnotation = Annot.Create(null, Annot.Type.e_3D, null); // For Compiler. Should never execute this break; } if (!(annotation is FreeText)) // Quick Fix, need to revamp it { pdfAnnotation.SetColor(AnnotationsMannager.ConvertColor(new double[] { annotation.ColorRed(), annotation.ColorGreen(), annotation.ColorBlue() }), 3); } _currentDoc.GetPage(annotation.Page()).AnnotPushBack(pdfAnnotation); return(pdfAnnotation); }