コード例 #1
0
ファイル: PdfDisplayMedia.cs プロジェクト: AxlOnGit/Catalist
        /// <summary>
        /// Set media window
        /// </summary>
        /// <param name="MediaWindow">Media window</param>
        /// <param name="Width">Floating window width</param>
        /// <param name="Height">Floating window height</param>
        /// <param name="Position">Floating window position</param>
        /// <param name="TitleBar">Floating window title bar</param>
        /// <param name="Resize">Floating window resize</param>
        /// <param name="Title">Floating window title</param>
        /// <remarks>
        /// <para>
        /// All optional arguments are applicable to floating window only.
        /// </para>
        /// </remarks>
        public void SetMediaWindow
        (
            MediaWindow MediaWindow,
            Int32 Width             = 0,
            Int32 Height            = 0,
            WindowPosition Position = WindowPosition.Center,
            WindowTitleBar TitleBar = WindowTitleBar.TitleBarWithCloseButton,
            WindowResize Resize     = WindowResize.KeepAspectRatio,
            String Title            = null
        )
        {
            // set media play window code
            MediaScreenParamBE.AddInteger("/W", (Int32)MediaWindow);

            // all choices but floating window
            if (MediaWindow != MediaWindow.Floating)
            {
                MediaScreenParamBE.Remove("/F");
                return;
            }

            // play rendition in floating window
            // Table 9.19 page 774
            PdfDictionary FloatingWindow = new PdfDictionary(this);

            MediaScreenParamBE.AddDictionary("/F", FloatingWindow);

            // window's dimensions
            if (Width == 0 || Height == 0)
            {
                Width  = 320;
                Height = 180;
            }
            FloatingWindow.AddFormat("/D", "[{0} {1}]", Width, Height);

            FloatingWindow.AddInteger("/P", (Int32)Position);

            FloatingWindow.AddBoolean("/T", TitleBar != WindowTitleBar.NoTitleBar);
            if (TitleBar == WindowTitleBar.NoTitleBar)
            {
                return;
            }

            FloatingWindow.AddInteger("/R", (Int32)Resize);

            if (Title != null)
            {
//			if(Document.Encryption == null)
//				{
//				FloatingWindow.AddFormat("/TT", "[() ({0})]", Title);
//				}
//			else
//				{
                FloatingWindow.AddFormat("/TT", "[{0} {1}]", Document.TextToPdfString(String.Empty, this), Document.TextToPdfString(Title, this));
//				}
            }

            return;
        }
コード例 #2
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;
        }
コード例 #3
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;
        }