Esempio n. 1
0
 /// <summary>
 /// Add annotation file attachement with no icon
 /// </summary>
 /// <param name="AnnotRect">Annotation rectangle</param>
 /// <param name="EmbeddedFile">Embedded file</param>
 /// <returns>PdfAnnotation</returns>
 /// <remarks>The AnnotRect is any area on the page. When the user right click this
 /// area a floating menu will be displayed.</remarks>
 public PdfAnnotation AddFileAttachment
 (
     PdfRectangle AnnotRect,
     PdfEmbeddedFile EmbeddedFile
 )
 {
     return(new PdfAnnotation(this, AnnotRect, new AnnotFileAttachment(EmbeddedFile, FileAttachIcon.NoIcon)));
 }
Esempio n. 2
0
 /// <summary>
 ///     File attachement constructor (no icon)
 /// </summary>
 /// <param name="EmbeddedFile">Embedded file</param>
 public AnnotFileAttachment
 (
     PdfEmbeddedFile EmbeddedFile
 ) : base("/FileAttachment")
 {
     this.EmbeddedFile = EmbeddedFile;
     Icon = FileAttachIcon.NoIcon;
 }
Esempio n. 3
0
 /// <summary>
 ///     File attachement constructor
 /// </summary>
 /// <param name="EmbeddedFile">Embedded file</param>
 /// <param name="Icon">Icon enumeration</param>
 public AnnotFileAttachment
 (
     PdfEmbeddedFile EmbeddedFile,
     FileAttachIcon Icon
 ) : base("/FileAttachment")
 {
     this.EmbeddedFile = EmbeddedFile;
     this.Icon         = Icon;
 }
Esempio n. 4
0
        /// <summary>
        /// File attachement
        /// </summary>
        /// <param name="Page">Associated page</param>
        /// <param name="AnnotRect">Annotation rectangle</param>
        /// <param name="EmbeddedFile">Embedded file name</param>
        /// <param name="Icon">Icon</param>
        /// <remarks>
        /// <para>
        /// PDF specifications File Attachment Annotation page 637 table 8.35
        /// </para>
        /// </remarks>
        public PdfAnnotation
        (
            PdfPage Page,
            PdfRectangle AnnotRect,
            PdfEmbeddedFile EmbeddedFile,
            FileAttachIcon Icon = FileAttachIcon.PushPin
        ) : base(Page.Document)
        {
            // annotation subtype
            Dictionary.Add("/Subtype", "/FileAttachment");

            // add page reference
            Dictionary.AddIndirectReference("/FS", EmbeddedFile);

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

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

            // exit
            return;
        }
Esempio n. 5
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;
        }
Esempio n. 6
0
        /// <summary>
        /// Display media constructor
        /// </summary>
        /// <param name="MediaFile">Embedded media file</param>
        /// <param name="MimeType">Mime type</param>
        /// <remarks>
        /// <para>
        /// If mime type is null the program will try to convert file extension
        /// to mime type. If conversion is not available application exception will be raised.
        /// </para>
        /// </remarks>
        public PdfDisplayMedia
        (
            PdfEmbeddedFile MediaFile,
            String MimeType = null
        ) : base(MediaFile.Document)
        {
            // save media file
            this.MediaFile = MediaFile;

            // save mimetype
            if (MimeType == null)
            {
                MimeType = MediaFile.MimeType;
            }
            if (String.IsNullOrWhiteSpace(MimeType))
            {
                throw new ApplicationException("MIME type is not defined");
            }

            // rendition dictionary page 759 Section 9.1.2 Table 9.1
            Rendition = new PdfDictionary(this);
            Dictionary.AddDictionary("/R", Rendition);

            // media clip
            MediaClip = new PdfDictionary(this);
            Rendition.AddDictionary("/C", MediaClip);

            // Media clip dictionary T 9.9
            TempFilePermissions = new PdfDictionary(this);
            MediaClip.AddDictionary("/P", TempFilePermissions);

            // media play
            MediaPlay = new PdfDictionary(this);
            Rendition.AddDictionary("/P", MediaPlay);

            // media play BE
            MediaPlayBE = new PdfDictionary(this);
            MediaPlay.AddDictionary("/BE", MediaPlayBE);

            // media screen parameters
            MediaScreenParam = new PdfDictionary(this);
            Rendition.AddDictionary("/SP", MediaScreenParam);

            // media screen parameters BE
            MediaScreenParamBE = new PdfDictionary(this);
            MediaScreenParam.AddDictionary("/BE", MediaScreenParamBE);

            // Section 8.5 page 669 table 8.64
            // type of action playing multimedia content
            Dictionary.Add("/S", "/Rendition");

            // media clip data page 762
            Rendition.Add("/S", "/MR");

            // Table 9.6 page 762
            MediaClip.AddPdfString("/CT", MimeType);
            MediaClip.AddIndirectReference("/D", MediaFile);
            MediaClip.Add("/S", "/MCD");
            MediaClip.Add("/Type", "/MediaClip");

            // Operation to perform when action is triggered. Valid options are 0 or 4
            // OP=0 force the Rendition dictionary to take over the annotation
            Dictionary.Add("/OP", "0");

            // allow reader to always create temporary file (other options do not work)
            // Media clip dictionary T 9.10 page 766
            TempFilePermissions.AddPdfString("/TF", "TEMPALWAYS");

            // do not display control
            MediaPlayBE.AddBoolean("/C", false);

            // repeat count of 1
            MediaPlayBE.Add("/RC", "1.0");

            // media scale and position within annotation rectangle PDF default is 5
            // /F=2 strech media to fit annotation
            MediaPlayBE.Add("/F", "2");

            // play rendition in annotation rectangle
            MediaScreenParamBE.Add("/W", "3");

            // exit
            return;
        }