I need to extract video file which is embedded in pdf file. i could find the video which is in annotation so that i can’t save it separately. i need to save this file how do i achieve this?
Ex:
iTextSharp – how to open/read/extract a file attachment?
he has extracted attachement like the way i need to extract the video.
here is my code:
string FileName = AppDomain.CurrentDomain.BaseDirectory + "raven test.pdf";
PdfReader pdfreader = new PdfReader(FileName);
PdfDictionary PageDictionary = pdfreader.GetPageN(1);
PdfArray Annots = PageDictionary.GetAsArray(PdfName.ANNOTS);
if ((Annots == null) || (Annots.Length == 0))
return;
foreach (PdfObject oAnnot in Annots.ArrayList)
{
PdfDictionary AnnotationDictionary = (PdfDictionary)PdfReader.GetPdfObject(oAnnot);
if (AnnotationDictionary.Get(PdfName.SUBTYPE).Equals(PdfName.RICHMEDIA))
{
if (AnnotationDictionary.Keys.Contains(PdfName.RICHMEDIACONTENT))
{
PdfDictionary oRICHContent = AnnotationDictionary.GetAsDict(PdfName.RICHMEDIACONTENT); // here i could see the video embeded but it is in annotation, how do i save this file?
}
}
}
For this one you’ll want to reference the Adobe Supplement to ISO 32000, BaseVersion 1.7, ExtensionLevel 3 official spec. Below is the basic code although you’ll probably want to throw in some more
nullchecks. See the comments for any questions. Just a note, not all embedded movies use the RichMedia format, some are just special attachments so this won’t get them all.