Take a survey

Developing Applications Using APIs > Assembling PDF Documents > Working with File Attachments > Extracting file attachments

Extracting file attachments
You can use the FileAttachments result element to return one or more file attachments from source documents. Each file attachment is returned as a separate data stream, and the Assembler service maps each stream to a unique name in the outputs map.
Information about the mapping between names and streams is returned in an XML document that also contains information about each returned file attachment.
This example returns all file attachments associated with the document doc3.pdf.
Example: Extracting all file attachments
<FileAttachments result="attachmentInfo.xml" nameKeys="*" extract="true">
	<PDF source="doc3.pdf"/>
	<FilenameEncoding encoding="ISO-8859-1"/>
</FileAttachments>
Note the following points about this example:
The result attribute specifies the XML document to be returned containing information about the file attachments. This document conforms to the FileAttachments schema; see the Document Description XML Reference for complete information.
All page-level file attachments in the PDF pages specified for the source document are returned; you cannot specify individual page-level file attachments to return. If you specify the pages attribute on the PDF source element, only file attachments on that range of pages would be returned. In the example, all page-level file attachments are returned.
The nameKeys attribute is a string specifying a list of document-level file attachments to be returned. It may be a single name or a comma-separated list such as "doc1, doc2, doc3". The value "*", as in the example above, requests that all document-level file attachments be returned. If you do not specify this attribute, no document-level file attachments are returned.
The extract attribute has a default value of true, so it is shown in the example only for convenience. If you specify a value of false, the file attachments are not actually returned to you as streams. Only the XML document is returned.
The FilenameEncoding element specifies an encoding to use to decode the file names of the file attachments. You can specify more than one of these elements in case one of them is unknown to the client.
The following example extracts a single document-level file attachment. It provides several encodings that can be used to decode the stored filename. The result XML document is encoded with UTF-8.
Example: Extracting a single file attachment
<FileAttachments result="attachmentInfo.xml" nameKeys="data1" >
	<PDF source="doc3.pdf"/>
	<FilenameEncoding encoding="ISO-10646-UCS-2"/>
	<FilenameEncoding encoding="UTF-8"/>
	<FilenameEncoding encoding="ISO-8859-1"/>
</FileAttachments>
This example extracts multiple files attached to the PDF document.
Example: Extracting multiple file attachments
<FileAttachments result="attachmentInfo.xml" nameKeys="doc1,doc2,doc3" >
	<PDF source="doc3.pdf"/>
	<FilenameEncoding encoding="ISO-8859-1"/>
</FileAttachments>
In this example, page-level file attachments are extracted from pages 2-3 only. Default filename encoding is used to decode the stored filename.
Example: Extracting file attachments from specific pages
<FileAttachments result="attachmentInfo.xml">
	<PDF source="doc3.pdf" pages="2-3"/>
	<FilenameEncoding encoding="ISO-8859-1"/>
</FileAttachments>

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/assemblePDFFile_attachments.99.6.html