Skip to main content

Posts

How to Extract Embedded Files from PDF Documents in C# (Including Attachment Annotations)

  PDF files can contain more than text and images. In some cases, they also include embedded files such as Excel spreadsheets, Word documents, CSV files, or supporting reports. For example, a project review PDF might contain an Excel workbook with detailed financial data and a CSV file attached to a chart. If you need those files for further processing, manually opening the PDF and saving each attachment can become tedious, especially when handling multiple documents. In C#, you can extract these embedded files directly from the PDF and save them to a local directory. However, there's an important detail: PDF attachments can be stored at the document level or attached to specific pages as annotations. This tutorial covers both types and shows how to extract them into separate folders without overwriting files that share the same name. Prerequisites Before getting started, install the required PDF processing library in your C# project. In Visual Studio, open Tools > NuGet Package...