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> /// 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> /// 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> /// Activate annotation when page becomes visible. /// </summary> /// <param name="Activate">Activate or not-activate annotation.</param> public void ActivateActionWhenPageIsVisible ( bool Activate ) { // applicable to screen action if (AnnotAction.GetType() == typeof(AnnotDisplayMedia)) { // play video when page becomes visible if (Activate) { Dictionary.AddFormat("/AA", "<</PV {0} 0 R>>", ((AnnotDisplayMedia)AnnotAction).DisplayMedia.ObjectNumber); } else { Dictionary.Remove("/AA"); } } }
/// <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 }