Hi,
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?
Hi,
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?
Hi,
Thanks a lot for this solution. It's really working fine.
Your answer has solved one of my biggest issue.
Thanks again
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
this.
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 http://www.adobe.com/devnet/acrobat/pdfs/adobe_supplement_iso32000.pdf)
and is not part of ISO32000. The code would look along the following
lines:
// 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
{
///
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();
instances.PushBack(instance);
config.Put(“Instances”, instances);
Obj configs = doc.CreateIndirectArray();
configs.PushBack(config);
mc.Put(“Configurations”, configs);
// Optional: Fill-in RichMediaSettings dictionary
// Obj ms = dict.PutDict(“RichMediaSettings”);
//…
// add annotation to the page.
Page page = doc.GetPage(1);
page.AnnotPushBack(a);
}
static void Main(string[] args)
{
PDFNet.Initialize();
try
{
using (PDFDoc doc = new PDFDoc("…/…/…/…/TestFiles/numbered.pdf"))
{
doc.InitSecurityHandler();
EmbedFlash(doc);
doc.Save("…/…/…/…/TestFiles/Output/our.pdf", SDFDoc.SaveOptions.e_linearized);
}
}
catch (PDFNetException e)
{
System.Console.WriteLine(e.Message);
}
}
}
}
The above sample code referenced following Flash file:
http://www.pdftron.com/assets/flash/header.swf (which you can save under PDFNet\Samples\TestFiles).
For example of how to extract flash movies and other RichMedia from
PDF please see:
http://groups.google.com/group/pdfnet-sdk/browse_thread/thread/d3ef6d8d15691bd5/ba33d2cb885cdfbb
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
http://blog.pdftron.com/2013/09/11/working-with-pdf-richmedia-annotations/