Exemplo n.º 1
0
        /// <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;
        }
Exemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////
        // Initial Object Array
        ////////////////////////////////////////////////////////////////////

        private void ConstructorHelper
        (
            double Width,       // page width
            double Height,      // page height
            double ScaleFactor, // scale factor from user units to points (i.e. 72.0 for inch)
            string FileName,
            Stream OutputStream
        )
        {
            // set scale factor (user units to points)
            this.ScaleFactor = ScaleFactor;

            // set epsilon (1/300 of an inch in user units)
            Epsilon = 72.0 / (300.0 * ScaleFactor);

            // save page default size
            PageSize = new SizeD(Width, Height);

            // PDF document root object the Catalog object
            CatalogObject = new PdfObject(this, ObjectType.Dictionary, "/Catalog");

            // add viewer preferences
            CatalogObject.Dictionary.Add("/ViewerPreferences", "<</PrintScaling/None>>");

            // Parent object for all pages
            PagesObject = new PdfObject(this, ObjectType.Dictionary, "/Pages");

            // add indirect reference to pages within the catalog object
            CatalogObject.Dictionary.AddIndirectReference("/Pages", PagesObject);

            // create trailer dictionary
            TrailerDict = new PdfDictionary(this);

            // add /Root
            TrailerDict.AddIndirectReference("/Root", CatalogObject);

            // document id
            DocumentID = RandomByteArray(16);

            // add /ID
            TrailerDict.AddFormat("/ID", "[{0}{0}]", ByteArrayToPdfHexString(DocumentID));

            // create file using file name
            if (FileName != null)
            {
                // save file name
                this.FileName = FileName;

                // constructor helper
                PdfFile = new PdfBinaryWriter(new FileStream(FileName, FileMode.Create, FileAccess.Write,
                                                             FileShare.None));
            }

            // write to caller's file or memory stream
            else
            {
                PdfFile = new PdfBinaryWriter(OutputStream);
            }

            // write PDF version number
            PdfFile.WriteString("%PDF-1.7\n");

            // add this comment to tell compression programs that this is a binary file
            PdfFile.WriteString("%\u00b5\u00b5\u00b5\u00b5\n");

            // exit
        }
        /// <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;
        }