How to Add File Attachments Programmatically to PDFs Using Adobe API
Question details
Developers need a step-by-step method to programmatically insert file attachments into a dynamically generated HTML-to-PDF document.

- Product
- Adobe PDF Services API
- Device & OS
- not provided
- Scenario
- Generating a PDF from HTML source code and embedding supporting files directly into the resulting PDF document via API.
- Observed behavior
- The user aims to automate the creation of a PDF and the inclusion of file attachments within it using Adobe's development tools.
Ensure you have your Adobe PDF Services API credentials (client ID and client secret) properly configured in your development environment and the required SDK installed for your chosen programming language.
Use HTML-to-PDF and Document Manipulation Endpoints
Execute a two-step process by generating the base PDF first, then using document manipulation services to embed your attachments.
Since the HTML-to-PDF endpoint primarily handles the conversion of web content to document layouts, embedding supplementary files requires a subsequent operation. You must first render the HTML into a standard PDF, and then utilize the combine or manipulation endpoints to attach your supporting files into the newly created document.
Set up your API context by passing your Adobe client credentials into the PDF Services SDK client initialization method.
Invoke the HTML-to-PDF generation endpoint, passing your dynamic HTML file or ZIP archive to create the initial PDF document.
Save the resulting PDF locally or keep it in your application's secure memory stream for the next operation.
Create a new Combine or Document Manipulation operation, setting the newly generated PDF as the base and specifying the supplementary files as attachments to be embedded.
Execute the manipulation operation and save the final, combined PDF document containing all embedded file attachments to your destination path.

Manually Add and Manage PDF Attachments with WPS Office
If you are reviewing generated PDFs or simply need to add attachments without writing code, WPS Office provides an intuitive, user-friendly interface to embed, extract, and manage PDF attachments effortlessly.
- 1. Open the PDF File: Launch WPS Office and open the target PDF document where you want to insert an attachment.
- 2. Access the Comment Tab: Navigate to the 'Comment' tab located on the top ribbon of the WPS PDF interface.
- 3. Insert the Attachment: Click the 'Attachment' tool icon, then click anywhere on the document page to place the attachment pin.
- 4. Select Your File: Browse your local computer directories in the popup window, select the supplementary file you wish to embed, and click 'Open' to finalize the attachment.

Frequently Asked Questions
Can I add attachments during the HTML-to-PDF conversion in a single API call?
Currently, Adobe PDF Services requires a sequential two-step process: first converting the HTML to a PDF document, and then utilizing the document manipulation endpoints to embed the file attachments into that generated PDF.
What programming languages are supported by Adobe PDF Services SDK?
The Adobe PDF Services API offers official SDKs for Node.js, Java, .NET, and Python, allowing you to seamlessly integrate document generation and attachment manipulation into your backend applications.
How do I extract attachments from an existing PDF programmatically?
You can use the Extract PDF operation provided by the API to retrieve structural elements, text, images, and any embedded file attachments from existing PDF documents.
Are there file size restrictions when embedding attachments?
Yes, Adobe PDF Services enforces a maximum payload limit for document operations (typically around 100MB, depending on your subscription tier). Ensure your combined HTML source and attached files do not exceed this limit.




