How To embed a flash in pdf through pdftron


I want to embed .swf files or audio/vedio files in pdf. Can anyone
tell me how can I do this. Is their any sample for this?


Thanks a lot for this solution. It's really working fine.
Your answer has solved one of my biggest issue.
Thanks again :slight_smile:

But I still have an issue of embedding Vedio/audio files in my PDF
through PDFTron.

Is it possible to embed Vedio/Audio file in my PDF through PDFTron.

It will be really greatful if you can provide me any solution for

Thanks in advance.

You would need to create a custom annotation type with “RichMedia”
Subtype. Please note that RichMedia annotation is a proprietary
Adobe’s extension (see
and is not part of ISO32000. The code would look along the following

// Assuming C# (JAVA,C/C++,VB is similar)
// This is a drop-in replacement for Annotation sample project

using pdftron;
using pdftron.Common;
using pdftron.Filters;
using pdftron.SDF;
using pdftron.PDF;

namespace AnnotationTestCS

/// Summary description for Class1.

class Class1
private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance();

static void EmbedFlash(PDFDoc doc)
string input_path = “…/…/…/…/TestFiles/”;

pdftron.PDF.Annot a = Annot.Create(doc, Annot.Type.e_RichMedia, new Rect(12, 632, 604, 771));
Obj dict = a.GetSDFObj();

Obj mc = dict.PutDict(“RichMediaContent”);

// Embed the flash file.
string flash_file = “header.swf”;
FileSpec fs = FileSpec.Create(doc, input_path + flash_file, true);

fs.GetSDFObj().PutString(“F”, flash_file); // Not sure if this is right for non-ascii file paths. Hopefuly in this case UF should be taken as authority.
fs.GetSDFObj().PutText(“UF”, flash_file);

// Create/find the asset NameTree.
NameTree assets = pdftron.SDF.NameTree.Create(doc, “Assets”);
assets.Put(System.Text.Encoding.UTF8.GetBytes(“header.swf”), fs.GetSDFObj());

mc.Put(“Assets”, assets.GetSDFObj());

Obj config = doc.CreateIndirectDict();
config.PutName(“Subtype”, “Flash”);

Obj instance = doc.CreateIndirectDict();
instance.Put(“Asset”, fs.GetSDFObj());
instance.PutDict(“Params”).PutName(“Binding”, “Background”);

Obj instances = doc.CreateIndirectArray();
config.Put(“Instances”, instances);

Obj configs = doc.CreateIndirectArray();

mc.Put(“Configurations”, configs);

// Optional: Fill-in RichMediaSettings dictionary
// Obj ms = dict.PutDict(“RichMediaSettings”);

// add annotation to the page.
Page page = doc.GetPage(1);

static void Main(string[] args)
using (PDFDoc doc = new PDFDoc("…/…/…/…/TestFiles/numbered.pdf"))
doc.Save("…/…/…/…/TestFiles/Output/our.pdf", SDFDoc.SaveOptions.e_linearized);
catch (PDFNetException e)


The above sample code referenced following Flash file: (which you can save under PDFNet\Samples\TestFiles).

For example of how to extract flash movies and other RichMedia from
PDF please see:

AnnotationTest.cs (2.64 KB)

header.swf (137 KB)

For more info related to RichMedia annotations (specifically extraction & playback) see:

Working with PDF RichMedia annotations