Esempio n. 1
0
        private static void CreateRichMediaAnnotations(PdfFixedDocument document, PdfFont font, Stream flashStream)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

            page.Graphics.DrawString("Rich media annotations", font, blackBrush, 50, 50);

            byte[] flashContent = new byte[flashStream.Length];
            flashStream.Read(flashContent, 0, flashContent.Length);

            PdfRichMediaAnnotation rma = new PdfRichMediaAnnotation();

            page.Annotations.Add(rma);
            rma.VisualRectangle     = new PdfVisualRectangle(100, 100, 400, 400);
            rma.FlashPayload        = flashContent;
            rma.FlashFile           = "clock.swf";
            rma.ActivationCondition = PdfRichMediaActivationCondition.PageVisible;
        }
        public static void Main()
        {
            // NOTE:
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            const string PathToFile = "RichMediaAnnotations.pdf";

            using (var pdf = new PdfDocument())
            {
                PdfPage page = pdf.Pages[0];

                var bounds = new PdfRectangle(10, 50, 200, 100);
                PdfFileSpecification   sound = pdf.CreateFileAttachment(@"..\Sample Data\sound.mp3");
                PdfRichMediaAnnotation annot = page.AddRichMediaAnnotation(bounds, sound, PdfRichMediaContentType.Sound);
                annot.Activation.ActivationMode = PdfRichMediaActivationMode.OnPageOpen;

                pdf.Save(PathToFile);
            }

            Console.WriteLine($"The output is located in {Environment.CurrentDirectory}");
        }
Esempio n. 3
0
        private static void CreateRichMediaAnnotations(PdfFixedDocument document, PdfFont font, Stream flashStream)
        {
            PdfBrush blackBrush = new PdfBrush();

            PdfPage page = document.Pages.Add();

            page.Graphics.DrawString("Rich media annotations", font, blackBrush, 50, 50);

            byte[] flashContent = new byte[flashStream.Length];
            flashStream.Read(flashContent, 0, flashContent.Length);

            PdfRichMediaAnnotation rma = new PdfRichMediaAnnotation();
            page.Annotations.Add(rma);
            rma.VisualRectangle = new PdfVisualRectangle(100, 100, 400, 400);
            rma.FlashPayload = flashContent;
            rma.FlashFile = "clock.swf";
            rma.ActivationCondition = PdfRichMediaActivationCondition.PageVisible;
        }