PDF Extractor SDK Explained: Extract Attachments from PDF - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

PDF Extractor SDK Explained: Extract Attachments from PDF

  • Home
  • /
  • Articles
  • /
  • PDF Extractor SDK Explained: Extract Attachments from PDF

Sometimes a PDF file contains some attachments. In this tutorial, we’re going to see how we can extract that attachment and save it. We are having one sample PDF file which contains some attachments hidden in it. We see three different format files here, one TIFF file, one PNG file, and the other is an EMF file.

START YOUR FREE TRIAL HERE

How to Extract Attachments from PDF

Now we’re going to see how we can extract these attachments and save them in our local guide. I already have this PDF file and always make sure it is copied.

Extract Attachments

We are using the Attachment Extractor class. We’re going to load documents into it. We are iterating through all the attachments and saving them. If you want to have some extra information about attachments, we can use some methods, like for example, we have the method Get File Size to get the size of the file. We have the method Get File Name to get the name of the file. Now, I am going to create the instance of (Attachment Extractor extractor = new AttachmentExtractor(“demo”, “demo”)).

Extract PDF Attachments

Let me Load the Document extractor.LoadDocumentFromFile(“sample_program5.pdf”). Let us Iterate it through, I’m having the for Loop for (int index = 0; index < extractor.Count; index++). Now we need to save it somewhere extractor.Save(index, extractor.GetFileName(index)); and let's display the Console.WriteLine($"File: {extractor.GetFileName(index)}, Size: {extractor.GetSize(index)}"). Extract Attachments PDF

Now execute it and we can see that it is able to get the three attachments from the PDF. let’s check whether it is stored in the bin folder or not. We can see three different format files, one is the sample.png, the second one samplemetafile.emf and the other is ab.tif

Extract Attachments with PDF Extractor SDK

Tutorials:

prev
next