Click here to Skip to main content
12,511,383 members (133,565 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
Hello Everyone,
How can we generate a pdf file with Video and Image slider.
Posted 14-Jan-13 23:35pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Hello there, have you ever used itextsharp? Its a beautiful library, it was a java library ported to c#.

http://sourceforge.net/projects/itextsharp/[^]

The sample code i've got below is for embedding a swf file into a pdf. With this sameple you should be able to try whatever other formats you may have and see if they will work by importing them into a pdf.

Please let me know if you have any questions.

Usings

using System;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.richmedia;

Code

static void Main(string[] args)
        {
            CreatePdfWithMedia(@"C:\temp\test.pdf");
        }
 
        public static void CreatePdfWithMedia(string file)
        {
            string day = DateTime.Now.ToString("dd/MM/yyyy");
 
            Document document = new Document();
            //--------------------
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(file, FileMode.Create));
            writer.SetPdfVersion(PdfWriter.PDF_VERSION_1_7);
            writer.AddDeveloperExtension(PdfDeveloperExtension.ADOBE_1_7_EXTENSIONLEVEL3);
            //--------------------
            document.Open();
            //--------------------
            RichMediaAnnotation media = new RichMediaAnnotation(writer, new Rectangle(36, 400, 559, 806));
            PdfFileSpecification fs = PdfFileSpecification.FileEmbedded(writer, @"C:\temp\test.swf", "1.swf", null);
            PdfIndirectReference asset = media.AddAsset("1.swf", fs);
            RichMediaConfiguration configuration = new RichMediaConfiguration(PdfName.FLASH);
            RichMediaInstance instance = new RichMediaInstance(PdfName.FLASH);
            RichMediaParams flashVars = new RichMediaParams();
            String vars = day;
            //--------------------
            flashVars.FlashVars = vars;
            instance.Params = flashVars;
            instance.Asset = asset;
            configuration.AddInstance(instance);
            //--------------------
            PdfIndirectReference configurationRef = media.AddConfiguration(configuration);
            RichMediaActivation activation = new RichMediaActivation();
            activation.Configuration = configurationRef;
            media.Activation = activation;
            //--------------------
            PdfAnnotation richMediaAnnotation = media.CreateAnnotation();
            richMediaAnnotation.Flags = PdfAnnotation.FLAGS_PRINT;
            writer.AddAnnotation(richMediaAnnotation);
            //--------------------
            document.Close();
        }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100