Example #1
0
        /// <summary>
        /// PDF screen annotation constructor
        /// </summary>
        /// <param name="Page">Associated page</param>
        /// <param name="AnnotRect">Annotation rectangle</param>
        /// <param name="DisplayMedia">Display media class</param>
        public PdfAnnotation
        (
            PdfPage Page,
            PdfRectangle AnnotRect,
            PdfDisplayMedia DisplayMedia
        ) : base(Page.Document)
        {
            // annotation subtype
            Dictionary.Add("/Subtype", "/Screen");

            // action reference dictionary
            Dictionary.AddIndirectReference("/A", DisplayMedia);
            this.DisplayMedia = DisplayMedia;

            // add page reference
            Dictionary.AddIndirectReference("/P", Page);

            // add annotation reference
            DisplayMedia.Dictionary.AddIndirectReference("/AN", this);

            // constructor helper method
            ContructorHelper(Page, AnnotRect);

            // exit
            return;
        }
Example #2
0
 /// <summary>
 ///     Display media annotation action constructor
 /// </summary>
 /// <param name="DisplayMedia">PdfDisplayMedia</param>
 public AnnotDisplayMedia
 (
     PdfDisplayMedia DisplayMedia
 ) : base("/Screen")
 {
     this.DisplayMedia = DisplayMedia;
 }
Example #3
0
 /// <summary>
 /// Add rendering screen action to page
 /// </summary>
 /// <param name="AnnotRect">Annotation rectangle</param>
 /// <param name="DisplayMedia">Display media object</param>
 /// <returns>PdfAnnotation</returns>
 public PdfAnnotation AddScreenAction
 (
     PdfRectangle AnnotRect,
     PdfDisplayMedia DisplayMedia
 )
 {
     return(new PdfAnnotation(this, AnnotRect, new AnnotDisplayMedia(DisplayMedia)));
 }
Example #4
0
        /// <summary>
        /// Add rendering screen action to page
        /// </summary>
        /// <param name="Rect">Annotation rectangle</param>
        /// <param name="FileName">Media file name</param>
        /// <param name="WidthPix">Video width in pixels</param>
        /// <param name="HeightPix">Video height in pixels</param>
        /// <param name="MimeType">Media file Mime type</param>
        public void AddScreenAction
        (
            PdfRectangle Rect,
            String FileName,
            Int32 WidthPix  = 0,
            Int32 HeightPix = 0,
            String MimeType = null
        )
        {
            // create embedded media file
            PdfEmbeddedFile MediaFile = new PdfEmbeddedFile(Document, FileName);

            // Section 8.5 page 669 table 8.64
            PdfDisplayMedia ScreenAction = new PdfDisplayMedia(MediaFile, MimeType);

            // create PdfObject for annotation
            PdfAnnotation Annotation = new PdfAnnotation(this, Rect, ScreenAction);

//		Annotation.DisplayBorder(0.1);

            // exit
            return;
        }
Example #5
0
        /// <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))
            {
                PdfDisplayMedia 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
                AnnotFileAttachment File = (AnnotFileAttachment)AnnotAction;
                Dictionary.AddIndirectReference("/FS", File.EmbeddedFile);

                if (File.Icon != FileAttachIcon.NoIcon)
                {
                    // icon
                    Dictionary.AddName("/Name", File.Icon.ToString());
                }
                else
                {
                    // no icon
                    PdfXObject XObject = new PdfXObject(Document, AnnotRect.Right, AnnotRect.Top);
                    Dictionary.AddFormat("/AP", "<</N {0} 0 R>>", XObject.ObjectNumber);
                }
            }

            // sticky notes
            else if (AnnotAction.GetType() == typeof(AnnotStickyNote))
            {
                // short cut
                AnnotStickyNote StickyNote = (AnnotStickyNote)AnnotAction;

                // icon
                Dictionary.AddName("/Name", StickyNote.Icon.ToString());

                // action reference dictionary
                Dictionary.AddPdfString("/Contents", StickyNote.Note);
            }

            // add annotation object to page dictionary
            PdfKeyValue 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
            return;
        }
        /// <summary>
        /// PDF screen annotation constructor
        /// </summary>
        /// <param name="Page">Associated page</param>
        /// <param name="AnnotRect">Annotation rectangle</param>
        /// <param name="DisplayMedia">Display media class</param>
        public PdfAnnotation(
			PdfPage				Page,
			PdfRectangle		AnnotRect,
			PdfDisplayMedia		DisplayMedia
			)
            : base(Page.Document)
        {
            // annotation subtype
            Dictionary.Add("/Subtype", "/Screen");

            // action reference dictionary
            Dictionary.AddIndirectReference("/A", DisplayMedia);
            this.DisplayMedia = DisplayMedia;

            // add page reference
            Dictionary.AddIndirectReference("/P", Page);

            // add annotation reference
            DisplayMedia.Dictionary.AddIndirectReference("/AN", this);

            // constructor helper method
            ContructorHelper(Page, AnnotRect);

            // exit
            return;
        }
Example #7
0
        /// <summary>
        /// Add rendering screen action to page
        /// </summary>
        /// <param name="Rect">Annotation rectangle</param>
        /// <param name="FileName">Media file name</param>
        /// <param name="WidthPix">Video width in pixels</param>
        /// <param name="HeightPix">Video height in pixels</param>
        /// <param name="MimeType">Media file Mime type</param>
        public void AddScreenAction(
            PdfRectangle	Rect,
            String			FileName,
            Int32			WidthPix = 0,
            Int32			HeightPix = 0,
            String			MimeType = null
            )
        {
            // create embedded media file
            PdfEmbeddedFile MediaFile = new PdfEmbeddedFile(Document, FileName);

            // Section 8.5 page 669 table 8.64
            PdfDisplayMedia ScreenAction = new PdfDisplayMedia(MediaFile, MimeType);

            // create PdfObject for annotation
            PdfAnnotation Annotation = new PdfAnnotation(this, Rect, ScreenAction);

            //		Annotation.DisplayBorder(0.1);

            // exit
            return;
        }