Q: I assume that some of PDFs I have created myself with Acrobat Pro 9
has video stored in a way other than this code expects.
However we have to be able to process all kind of embedded videos.
------------
A: Some of the PDF you send contain Adobe proprietary annotation type
called 'RichMedia'. This annotation type is described in
http://www.adobe.com/devnet/acrobat/pdfs/adobe_supplement_iso32000.pdf:
"The rich media annotation means that Flash applications, video,
audio, and other multimedia can be attached
to a PDF document. The rich media annotation incorporates the existing
3D annotation structure to
support multiple multimedia file assets, including Flash video and
compatible variations on the H.264
format."
You can identify and process 'RichMedia' and other custom annotations
as follows:
PageIterator itr = doc.GetPageIterator();
for (; itr.HasNext(); itr.Next())
{
Console.WriteLine("Page {0:d}: ", itr.GetPageNumber());
Page page = itr.Current();
int num_annots = page.GetNumAnnots();
for (int i = 0; i < num_annots; ++i)
{
Annot annot = page.GetAnnot(i);
if (annot.IsValid() == false) continue;
if (annot.GetType() == Annot.Type.e_Unknown)
{
Obj ad = annot.GetSDFObj();
if ("RichMedia" == ad.Get("Subtype").Value().GetName())
{
Rect bbox = annot.GetRect();
Console.WriteLine(" Position: {0:f}, {1:f}, {2:f}, {3:f}",
bbox.x1, bbox.y1, bbox.x2, bbox.y2);
Obj mc = ad.FindObj("RichMediaContent");
if (mc != null)
{
// NameTree is in pdftron.SDF namespace
NameTree assets = new NameTree(mc.FindObj("Assets"));
if (!assets.IsValid()) continue;
NameTreeIterator j = assets.GetIterator();
for (; j.HasNext(); j.Next())
{
string assent_name = j.Key().GetAsPDFText();
FileSpec file_spec = new FileSpec(j.Value());
Filter stm = file_spec.GetFileData();
if (stm != null)
{
FilterReader reader = new FilterReader(stm);
StdFile f = new StdFile(output_path + assent_name,
StdFile.OpenMode.e_write_mode);
FilterWriter writer = new FilterWriter(f);
writer.WriteFilter(reader);
writer.Flush();
f.Close();
}
}
}
}
}
}
}
All of the details are described in the reference manual.