private void DogAndCat() { // create embedded media file PdfEmbeddedFile EmbeddedMediaFile = new PdfEmbeddedFile(Document, "BugsBunny.mp4"); // Section 8.5 page 669 table 8.64 PdfDisplayMedia DisplayMedia = new PdfDisplayMedia(EmbeddedMediaFile); // display media options DisplayMedia.DisplayControls(true); // repeat count (zero is play indefinitly) DisplayMedia.RepeatCount(1); // DisplayMedia.SetMediaWindow(MediaWindow.Floating, 480, 270, WindowPosition.UpperLeft, WindowTitleBar.TitleBarWithCloseButton, WindowResize.KeepAspectRatio, "User video title"); PdfRectangle AnnotRect = ImageSizePos.ImageArea(160, 120, 1.5, 2.0, 5.5, 7.0, ContentAlignment.TopLeft); // create PdfObject for annotation PdfAnnotation Annotation = new PdfAnnotation(Page, AnnotRect, DisplayMedia); PdfXObject NormalAppearance = new PdfXObject(Document, AnnotRect.Width, AnnotRect.Height); NormalAppearance.SaveGraphicsState(); NormalAppearance.SetColorNonStroking(Color.CornflowerBlue); NormalAppearance.SetColorStroking(Color.DarkGoldenrod); NormalAppearance.DrawOval(0.0, 0.0, AnnotRect.Width, AnnotRect.Height, PaintOp.CloseFillStroke); NormalAppearance.RestoreGraphicsState(); Annotation.Appearance(NormalAppearance); Annotation.ActivateActionWhenPageIsVisible(false); return; }
private void Example1() { // create embedded media file PdfEmbeddedFile LooneyTunes = new PdfEmbeddedFile(Document, "LooneyTunes.mp4"); PdfDisplayMedia DisplayMedia = new PdfDisplayMedia(LooneyTunes); PdfRectangle AnnotRect = ImageSizePos.ImageArea(480, 360, new PdfRectangle(1.2, 6.2, 7.3, 8.3), ContentAlignment.MiddleRight); // create PdfObject for annotation PdfAnnotation Annotation = new PdfAnnotation(Page, AnnotRect, DisplayMedia); Annotation.ActivateActionWhenPageIsVisible(false); return; }
private void Benny() { // create embedded media file PdfEmbeddedFile EmbeddedMediaFile = new PdfEmbeddedFile(Document, "Benny.mov"); // Section 8.5 page 669 table 8.64 PdfDisplayMedia DisplayMedia = new PdfDisplayMedia(EmbeddedMediaFile); // repeat count (zero is play indefinitly) DisplayMedia.RepeatCount(0); PdfRectangle AnnotRect = ImageSizePos.ImageArea(1920, 1080, 1.5, 2.0, 5.5, 7.0, ContentAlignment.TopLeft); // create PdfObject for annotation PdfAnnotation Annotation = new PdfAnnotation(Page, AnnotRect, DisplayMedia); return; }
private void Example2() { // create embedded media file PdfEmbeddedFile EmbeddedMediaFile = new PdfEmbeddedFile(Document, "Ring01.wav"); PdfDisplayMedia DisplayMedia = new PdfDisplayMedia(EmbeddedMediaFile); //DisplayMedia.SetMediaWindow(MediaWindow.Hidden); PdfRectangle AnnotRect = new PdfRectangle(5.2, 3.7, 7.3, 5.8); // create PdfObject for annotation PdfAnnotation Annotation = new PdfAnnotation(Page, AnnotRect, DisplayMedia); PdfXObject Normal = AnnotationArea(AnnotRect.Width, AnnotRect.Height, Color.Lavender, Color.Indigo, "Normal"); PdfXObject RollOver = AnnotationArea(AnnotRect.Width, AnnotRect.Height, Color.Yellow, Color.Brown, "RollOver"); PdfXObject Down = AnnotationArea(AnnotRect.Width, AnnotRect.Height, Color.LightPink, Color.DarkRed, "Down"); Annotation.Appearance(Normal, RollOver, Down); return; }
/// <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; }
public PdfFileSpecification(PdfDocument document, string fileName, PdfEmbeddedFile embeddedFile) : this(document) { this.FileName = fileName; this.EmbeddedFile = embeddedFile; }
/// <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; }
/// <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; }