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);
}
view raw tx.cs hosted with ❤ by GitHub

The attachment is represented by the EmbeddedFile TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
EmbeddedFile Class
The EmbeddedFile class represents a file embedded in another document.
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.