We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Extract audio files from PDF using Aspose.PDF for .NET

Hi,Support:
I want to extract audios from this pdf file, why the api fails to do for this file?
Thanks for your help.
This api(Apose.pdf.dll v17.7) runs in win10/Net4.0/Vb.net2017.
Cannot_Extract_Audios.pdf (1.2 MB)

@ducaisoft

The annotations in the attached PDF are not of regular RichMediaAnnotation type. Instead, they are screen annotations and audio files have been clipped to it for play. In order to extract audio files from such type of annotations, you need to use below code snippet:

[C#]

if (annotation is ScreenAnnotation)
{
 var ann = annotation as ScreenAnnotation;
 RenditionAction renditionaction = ann.Action as RenditionAction;
 MediaRendition mediaRendition = renditionaction.Rendition as MediaRendition;
 MediaClipData mediaclip = mediaRendition.MediaClip as MediaClipData;
 FileStream fs = new FileStream(dataDir + mediaclip.Data.Name, FileMode.CreateNew);
 mediaclip.Data.Contents.CopyTo(fs);
 fs.Close();
}

Thank your very much.
It works.

@ducaisoft

It is good to know that suggested solution worked for you. Please keep using our API and feel free to create a new topic in case you face any issue.