Products Technologies Demo Docs Blog Support Company

Streamline Document Workflows: Harness the Power of Embedded Attachments in PDFs in .NET C#

Embedding files as attachments to PDF documents offers significant benefits across multiple industries. This article shows how to create PDF documents with embedded attachments using TX Text Control .NET Server Core.

Streamline Document Workflows: Harness the Power of Embedded Attachments in PDFs in .NET C#

Businesses rely on PDF documents to communicate, collaborate, and transact efficiently. While PDFs have long been the format of choice because of their portability and consistent formatting, they offer more than just static pages of text and images. One of the most powerful features of PDF files is the ability to embed attachments - external files that are stored directly in the document.

Imagine receiving a financial report with the raw data behind the analysis attached, a signed contract bundled with supporting legal documents, or a technical manual with CAD files and video tutorials - all in one cohesive file.

PDF attachments turn documents into dynamic containers that consolidate all the necessary resources into a single, shareable package.

TX Text Control provides powerful PDF libraries for creating dynamic documents from templates and data such as JSON. But the SDK also offers powerful additional features that are important, such as embedding additional files as attachments to PDF documents. The following screenshot shows an NDA PDF document in Acrobat Reader with embedded files. The document embeds the original NDA as a MS Word DOCX document and an Excel spreadsheet.

Creating PDFs with attachments with TX Text Control

With attachments, PDFs become a single, unified container for all related materials, eliminating the need to juggle multiple files or send multiple emails. By bundling supporting documents - such as spreadsheets, contracts, or multimedia files - into a single PDF file, users can quickly access everything they need without having to search through folders or inboxes. A PDF should always be a current view of the current data, dynamically created with the current data and personalized for the specific audience or reader. This way, the user has all the information they need in a single container that can be opened on any device or platform.

Learn More

Despite being on the market for more than 30 years, the Portable Document Format (PDF) remains a dominant force in industries such as legal, healthcare, and finance. This blog post addresses the continued relevance of PDF, even as new formats and technologies emerge.

PDF is Dead, Long Live PDF: Why PDF Remains Relevant in a Changing Digital World

Key Business Use Cases

Embedding files as attachments to PDF documents offers significant benefits across a wide range of industries. Here are real business use cases from our customer projects where this capability is proving valuable:

  • Legal and Compliance: Ensure that all relevant information is included and accessible by attaching supporting documents to contracts, agreements, and legal filings. A PDF contains the primary contract, and attached files contain supporting documents (such as scanned agreements, customer correspondence, or court orders).
  • Financial Services: Financial institutions use PDF attachments for audits and reporting. Financial statements embed source data such as Excel spreadsheets, detailed revenue models, or financial reconciliation data.
  • Healthcare: Hospitals and research organizations attach supporting documentation to PDF-based patient or study reports. A clinical study report includes embedded lab results, imaging files (X-rays, CT scans), or physician comments for regulatory submissions.

Archive Documents with PDF/A-3b

The whole concept becomes interesting when archiving documents, as the ISO standard PDF/A-3b can be created, which allows attachments to be part of the document. This standard enables legally compliant archiving of document containers with supported attachments when PDF/A is required.

TX Text Control supports the creation of this ISO standard and can be used to programmatically create documents with attachments. To see how you can use TX Text Control to attach a text file to a PDF document, see the following sample code:

// create a non-UI ServerTextControl instance
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {

  tx.Create();
  // set dummy content
  tx.Text = "PDF Document Content";

  // read the content of the attachment
  string sAttachment = System.IO.File.ReadAllText("attachment.txt");

  // create the attachement
  TXTextControl.EmbeddedFile attachment =
     new TXTextControl.EmbeddedFile(
        "attachment.txt",
        sAttachment,
        null) {
       Description = "My Text File",
       Relationship = "Unspecified",
       MIMEType = "application/txt",
       CreationDate = DateTime.Now,
     };

  // attached the embedded file
  tx.DocumentSettings.EmbeddedFiles =
     new TXTextControl.EmbeddedFile[] { attachment };

  // save as PDF/A
  tx.Save("document.pdf", TXTextControl.StreamType.AdobePDFA);
}

The attachment is represented by the EmbeddedFile object. In the constructor you can add the filename, the data and additional metadata. In addition, the MIME type of the attachment (in this case, application/text), a textual description, a relationship, and the date the attachment was created are provided.

The relationship is an optional string that describes the relationship between the embedded file and the document it contains. It can be a predefined value. Alternatively, it should follow the rules for second-class names (ISO 32000-1, Annex E). Predefined values are Source, Data, Alternative, Supplement, or Unspecified.

Conclusion

PDF attachments are a powerful feature that can increase the utility and value of PDF documents. By embedding additional files directly into a PDF, users can consolidate all related materials into a single, shareable package. In industries such as legal, finance, and healthcare, where documents often require supporting materials to provide context or evidence, this capability is especially valuable.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETASP.NET CoreAttachments

How to Extract Attachments from PDF Documents in C#

This article shows how to extract attachments from PDF documents using TX Text Control .NET Server. The sample code extracts all attachments from a PDF document and saves them to disk.


ASP.NETASP.NET CoreAttachments

Add and Extract Attachments from PDF Documents in C#

PDF/A-3 allows files of any format to be embedded and can contain an unlimited number of embedded documents for different processes. This example shows adding and extracting attachments from PDF…


ASP.NETASP.NET CoreExtraction

Mining PDFs with Regex in C#: Practical Patterns, Tips, and Ideas

Mining PDFs with Regex in C# can be a powerful technique for extracting information from documents. This article explores practical patterns, tips, and ideas for effectively using regular…


ASP.NETASP.NET CoreForms

Streamline Data Collection with Embedded Forms in C# .NET

Discover how to enhance your C# .NET applications by embedding forms for data collection. This article explores the benefits of using Text Control's ASP.NET and ASP.NET Core components to create…


ASP.NETASP.NET CorePDF

Adding QR Codes to PDF Documents in C# .NET

This article explains how to add QR codes to PDF documents with the Text Control .NET Server component in C#. It provides the necessary steps and code snippets for effectively implementing this…