This tutorial will help you to extract audio from PDF files in C# and VB.NET using PDF Extractor SDK. Use the source code samples below to extract audio from PDF files.
using Bytescout.PDFExtractor; namespace ExtractAudio { class Program { static void Main(string[] args) { // Create Bytescout.PDFExtractor.MultimediaExtractor instance MultimediaExtractor extractor = new MultimediaExtractor(); extractor.RegistrationName = "demo"; extractor.RegistrationKey = "demo"; // Load PDF document extractor.LoadDocumentFromFile(@"sample.pdf"); int i = 0; // Initialize sound clips enumeration if (extractor.GetFirstAudio()) { do { string outputFileName = "audio" + i + extractor.GetCurrentAudioExtension(); // Save sound clip to file extractor.SaveCurrentAudioToFile(outputFileName); i++; } while (extractor.GetNextAudio()); // Advance sounds enumeration } } } }
Imports Bytescout.PDFExtractor Class Program Friend Shared Sub Main(ByVal args As String()) ' Create Bytescout.PDFExtractor.MultimediaExtractor instance Dim extractor As New MultimediaExtractor() extractor.RegistrationName = "demo" extractor.RegistrationKey = "demo" ' Load sample PDF document extractor.LoadDocumentFromFile("sample.pdf") Dim i As Integer = 0 ' Initialize sound clips enumeration If extractor.GetFirstAudio() Then Do Dim outputFileName As String = "audio" & i & extractor.GetCurrentAudioExtension() ' Save sound clip to file extractor.SaveCurrentAudioToFile(outputFileName) i = i + 1 Loop While extractor.GetNextAudio() ' Advance sounds enumeration End If End Sub End Class