/// <summary> /// Compare annotation web links /// </summary> /// <param name="Other">Other annotation</param> /// <returns>Result</returns> public override bool IsEqual ( AnnotAction Other ) { return(WebLinkStr == ((AnnotWebLink)Other).WebLinkStr); }
internal override bool IsEqual ( AnnotAction Other ) { return(this.EmbeddedFile.FileName == ((AnnotFileAttachment)Other).EmbeddedFile.FileName && this.Icon == ((AnnotFileAttachment)Other).Icon); }
/// <summary> /// Compare annotation links /// </summary> /// <param name="Other">Other annotation</param> /// <returns>Result</returns> public override bool IsEqual ( AnnotAction Other ) { return(this.LocMarkerName == ((AnnotLinkAction)Other).LocMarkerName); }
internal override bool IsEqual ( AnnotAction Other ) { return(this.DisplayMedia.MediaFile.FileName == ((AnnotDisplayMedia)Other).DisplayMedia.MediaFile.FileName); }
internal override bool IsEqual ( AnnotAction Other ) { return(this.WebLinkStr == ((AnnotWebLink)Other).WebLinkStr); }
/// <summary> /// Compare annotation display media /// </summary> /// <param name="Other">Other annotation</param> /// <returns>Result</returns> public override bool IsEqual ( AnnotAction Other ) { return(DisplayMedia.MediaFile.FileName == ((AnnotDisplayMedia)Other).DisplayMedia.MediaFile.FileName); }
/// <summary> /// Compare two annotation objects /// </summary> /// <param name="Other">Other annotation</param> /// <returns>Result</returns> public virtual bool IsEqual ( AnnotAction Other ) { throw new ApplicationException("AnnotAction IsEqual not implemented"); }
internal override bool IsEqual ( AnnotAction Other ) { return(LocMarkerName == ((AnnotLinkAction)Other).LocMarkerName); }
/// <summary> /// Compare sticky notes /// </summary> /// <param name="Other">Other annotation</param> /// <returns>Result</returns> public override bool IsEqual ( AnnotAction Other ) { AnnotStickyNote StickyNote = (AnnotStickyNote)Other; return(Note == StickyNote.Note && Icon == StickyNote.Icon); }
/// <summary> /// Compare file attachments /// </summary> /// <param name="Other">Other annotation</param> /// <returns>Result</returns> public override bool IsEqual ( AnnotAction Other ) { AnnotFileAttachment FileAttach = (AnnotFileAttachment)Other; return(EmbeddedFile.FileName == FileAttach.EmbeddedFile.FileName && Icon == FileAttach.Icon); }
/// <summary> /// Add text to text box. /// </summary> /// <param name="Font">Font</param> /// <param name="FontSize">Font size</param> /// <param name="Text">Text</param> /// <param name="AnnotAction">Annotation action</param> public void AddText ( PdfFont Font, double FontSize, string Text, AnnotAction AnnotAction ) { AddText(Font, FontSize, DrawStyle.Underline, Color.Blue, Text, AnnotAction); }
/// <summary> /// Add annotation action /// </summary> /// <param name="AnnotRect">Annotation rectangle</param> /// <param name="AnnotAction">Annotation action derived class</param> /// <returns>PdfAnnotation object</returns> public PdfAnnotation AddAnnotation ( PdfRectangle AnnotRect, AnnotAction AnnotAction ) { if (AnnotAction.GetType() == typeof(AnnotLinkAction)) { return(AddLinkAction(((AnnotLinkAction)AnnotAction).LocMarkerName, AnnotRect)); } return(new PdfAnnotation(this, AnnotRect, AnnotAction)); }
/// <summary> /// Compare two TextBox segments. /// </summary> /// <param name="Font">Segment font.</param> /// <param name="FontSize">Segment font size.</param> /// <param name="DrawStyle">Segment drawing style.</param> /// <param name="FontColor">Segment color.</param> /// <param name="AnnotAction">Segment annotation action.</param> /// <returns>Result</returns> internal Boolean IsEqual ( PdfFont Font, Double FontSize, DrawStyle DrawStyle, Color FontColor, AnnotAction AnnotAction ) { // test all but annotation action return(this.Font == Font && this.FontSize == FontSize && this.DrawStyle == DrawStyle && this.FontColor == FontColor && AnnotAction.IsEqual(this.AnnotAction, AnnotAction)); }
/// <summary> /// TextBox segment copy constructor. /// </summary> /// <param name="CopySeg">Source TextBox segment.</param> internal TextBoxSeg ( TextBoxSeg CopySeg ) { Font = CopySeg.Font; FontSize = CopySeg.FontSize; DrawStyle = CopySeg.DrawStyle; FontColor = CopySeg.FontColor; Text = string.Empty; AnnotAction = CopySeg.AnnotAction; return; }
/// <summary> /// TextBox segment copy constructor. /// </summary> /// <param name="CopySeg">Source TextBox segment.</param> internal TextBoxSeg ( TextBoxSeg CopySeg ) { this.Font = CopySeg.Font; this.FontSize = CopySeg.FontSize; this.DrawStyle = CopySeg.DrawStyle; this.FontColor = CopySeg.FontColor; Text = String.Empty; this.AnnotAction = CopySeg.AnnotAction; return; }
/// <summary> /// Add annotation action /// </summary> /// <param name="AnnotRect">Annotation rectangle</param> /// <param name="AnnotAction">Annotation action derived class</param> public void AddAnnotation ( PdfRectangle AnnotRect, AnnotAction AnnotAction ) { if (AnnotAction.GetType() == typeof(AnnotLinkAction)) { AddLinkAction(((AnnotLinkAction)AnnotAction).LocMarkerName, AnnotRect); } else { new PdfAnnotation(this, AnnotRect, AnnotAction); } }
internal static bool IsEqual ( AnnotAction One, AnnotAction Two ) { if (One == null && Two == null) { return(true); } if (One == null && Two != null || One != null && Two == null || One.GetType() != Two.GetType()) { return(false); } return(One.IsEqual(Two)); }
/// <summary> /// TextBox segment constructor. /// </summary> /// <param name="Font">Segment font.</param> /// <param name="FontSize">Segment font size.</param> /// <param name="DrawStyle">Segment drawing style.</param> /// <param name="FontColor">Segment color.</param> /// <param name="AnnotAction">Segment annotation action.</param> public TextBoxSeg ( PdfFont Font, double FontSize, DrawStyle DrawStyle, Color FontColor, AnnotAction AnnotAction ) { this.Font = Font; this.FontSize = FontSize; this.DrawStyle = DrawStyle; this.FontColor = FontColor; Text = string.Empty; this.AnnotAction = AnnotAction; }
internal void AddAnnotInternal ( PdfRectangle AnnotRect, AnnotAction AnnotAction ) { if (AnnotAction.GetType() == typeof(AnnotLinkAction)) { AddLinkAction(((AnnotLinkAction)AnnotAction).LocMarkerName, AnnotRect); } else { if (AnnotAction.GetType() == typeof(AnnotFileAttachment)) { ((AnnotFileAttachment)AnnotAction).Icon = FileAttachIcon.NoIcon; } new PdfAnnotation(this, AnnotRect, AnnotAction); } return; }
/// <summary> /// Compare two annotation objects /// </summary> /// <param name="One">First object</param> /// <param name="Two">Second object</param> /// <returns>Result</returns> public static bool IsEqual ( AnnotAction One, AnnotAction Two ) { if (One == null) { return(Two == null); } else { if (Two == null || One.GetType() != Two.GetType()) { return(false); } // the two annotations are the same type return(One.IsEqual(Two)); } }
/// <summary> /// PdfAnnotation constructor /// </summary> /// <param name="AnnotPage">Page object</param> /// <param name="AnnotRect">Annotation rectangle</param> /// <param name="AnnotAction">Annotation action</param> internal PdfAnnotation ( PdfPage AnnotPage, PdfRectangle AnnotRect, AnnotAction AnnotAction ) : base(AnnotPage.Document) { // save arguments this.AnnotPage = AnnotPage; this.AnnotRect = AnnotRect; this.AnnotAction = AnnotAction; // annotation subtype Dictionary.Add("/Subtype", AnnotAction.Subtype); // area rectangle on the page Dictionary.AddRectangle("/Rect", AnnotRect); // annotation flags. value of 4 = Bit position 3 print Dictionary.Add("/F", "4"); // border style dictionary. If /BS with /W 0 is not specified, the annotation will have a thin border Dictionary.Add("/BS", "<</W 0>>"); // web link if (AnnotAction.GetType() == typeof(AnnotWebLink)) { Dictionary.AddIndirectReference("/A", PdfWebLink.AddWebLink(Document, ((AnnotWebLink)AnnotAction).WebLinkStr)); } // jump to destination else if (AnnotAction.GetType() == typeof(AnnotLinkAction)) { if (Document.LinkAnnotArray == null) { Document.LinkAnnotArray = new List <PdfAnnotation>(); } Document.LinkAnnotArray.Add(this); } // display video or play sound else if (AnnotAction.GetType() == typeof(AnnotDisplayMedia)) { var DisplayMedia = ((AnnotDisplayMedia)AnnotAction).DisplayMedia; // action reference dictionary Dictionary.AddIndirectReference("/A", DisplayMedia); // add page reference Dictionary.AddIndirectReference("/P", AnnotPage); // add annotation reference DisplayMedia.Dictionary.AddIndirectReference("/AN", this); } // file attachment else if (AnnotAction.GetType() == typeof(AnnotFileAttachment)) { // add file attachment reference var File = (AnnotFileAttachment)AnnotAction; Dictionary.AddIndirectReference("/FS", File.EmbeddedFile); if (File.Icon != FileAttachIcon.NoIcon) { // icon Dictionary.AddName("/Name", File.Icon.ToString()); } else { // no icon var XObject = new PdfXObject(Document, AnnotRect.Right, AnnotRect.Top); Dictionary.AddFormat("/AP", "<</N {0} 0 R>>", XObject.ObjectNumber); } } // add annotation object to page dictionary var KeyValue = AnnotPage.Dictionary.GetValue("/Annots"); if (KeyValue == null) { AnnotPage.Dictionary.AddFormat("/Annots", "[{0} 0 R]", ObjectNumber); } else { AnnotPage.Dictionary.Add("/Annots", ((string)KeyValue.Value).Replace("]", string.Format(" {0} 0 R]", ObjectNumber))); } // exit }
/// <summary> /// Add text to text box. /// </summary> /// <param name="Font">Font</param> /// <param name="FontSize">Font size</param> /// <param name="DrawStyle">Drawing style</param> /// <param name="FontColor">Text color</param> /// <param name="Text">Text</param> /// <param name="AnnotAction">Web link</param> public void AddText ( PdfFont Font, double FontSize, DrawStyle DrawStyle, Color FontColor, string Text, AnnotAction AnnotAction ) { // text is null or empty if (string.IsNullOrEmpty(Text)) { return; } // create new text segment TextBoxSeg Seg; // segment array is empty or new segment is different than last one if (SegArray.Count == 0 || !SegArray[SegArray.Count - 1].IsEqual(Font, FontSize, DrawStyle, FontColor, AnnotAction)) { Seg = new TextBoxSeg(Font, FontSize, DrawStyle, FontColor, AnnotAction); SegArray.Add(Seg); } // add new text to most recent text segment else { Seg = SegArray[SegArray.Count - 1]; } // save text start pointer int TextStart = 0; // loop for characters for (int TextPtr = 0; TextPtr < Text.Length; TextPtr++) { // shortcut to current character char CurChar = Text[TextPtr]; // end of paragraph if (CurChar == '\n' || CurChar == '\r') { // append text to current segemnt Seg.Text += Text.Substring(TextStart, TextPtr - TextStart); // test for new line after carriage return if (CurChar == '\r' && TextPtr + 1 < Text.Length && Text[TextPtr + 1] == '\n') { TextPtr++; } // move pointer to one after the eol TextStart = TextPtr + 1; // add line AddLine(true); // update last character PrevChar = ' '; // end of text if (TextPtr + 1 == Text.Length) { return; } // add new empty segment Seg = new TextBoxSeg(Font, FontSize, DrawStyle, FontColor, AnnotAction); SegArray.Add(Seg); continue; } // character width double CharWidth = Font.CharWidth(FontSize, Seg.DrawStyle, CurChar); // space if (CurChar == ' ') { // test for transition from non space to space // this is a potential line break point if (PrevChar != ' ') { // save potential line break information LineBreakWidth = LineWidth; BreakSegIndex = SegArray.Count - 1; BreakPtr = Seg.Text.Length + TextPtr - TextStart; BreakWidth = Seg.SegWidth; } // add to line width LineWidth += CharWidth; Seg.SegWidth += CharWidth; // update last character PrevChar = CurChar; continue; } // add current segment width and to overall line width Seg.SegWidth += CharWidth; LineWidth += CharWidth; // for next loop set last character PrevChar = CurChar; // box width double Width = BoxWidth; if (FirstLineIndent != 0 && (LineArray.Count == 0 || LineArray[LineArray.Count - 1].EndOfParagraph)) { Width -= FirstLineIndent; } // current line width is less than or equal box width if (LineWidth <= Width) { continue; } // append text to current segemnt Seg.Text += Text.Substring(TextStart, TextPtr - TextStart + 1); TextStart = TextPtr + 1; // there are no breaks in this line or last segment is too long if (LineBreakWidth < LineBreakFactor * Width) { BreakSegIndex = SegArray.Count - 1; BreakPtr = Seg.Text.Length - 1; BreakWidth = Seg.SegWidth - CharWidth; } // break line BreakLine(); // add line up to break point AddLine(false); } // save text Seg.Text += Text.Substring(TextStart); // exit return; }