Take a survey

Developing Applications Using APIs > Assembling PDF Documents > Assembling and Disassembling PDF Documents > Understanding PDF packages > Working with package files

Working with package files
If you have a single PDF and an existing package file, you can convert the single PDF into a package file by specifying a PackageFiles source element. In the following example, single is a single PDF and pkg is a PDF package. The result, newPackage, is a package file containing the package specification that existed within pkg:
Example: Adding a single PDF as a package file (a document in the collection)
<PDF result="newPackage">
	<PDF source="pkg" />
	<PackageFiles source="single">
		<File filename="test.pdf" mimetype="application/pdf"/>
		<FieldData name="Description">example</FieldData>
	</PackageFiles>
</PDF>
Using a PackageFiles source, filter, or import element, you can determine which package files and specifications to assemble in the result. In the following example, the document single4, all Package files from pkg2, and only specific Package files from pkg3 are included as package files in newPackage. The document single5 is not included, because it cannot be selected by the nameKeys filter (it is a single PDF and has no namekey). The package specifications from all three packages are merged into one, beginning with pkg1, followed by pkg2, and finally pkg3.
Example: Using a PackageFiles filter element to select package files
<PDF result="newPackage">
	<PDF source="pkg1"/>
	<PackageFiles>
		<PDF source="pkg2"/>
		<PDF source="single4"/>
	</PackageFiles>
	<PackageFiles nameKeys="000001,000005">
		<PDF source="pkg3"/>
		<PDF source="single5"/>
	</PackageFiles>
</PDF>
Using a PackageFiles select element, you can select package files contained in the parent PDF result or parent PDF source document for the purpose of modifying the package files or adding metadata. In the following example, package files selected by nameKey from pkg1 are marked with a "Draft" watermark. All package files from pkg1 are then marked with an additional "For Review" watermark. Note that selected files are only marked if they are modifiable PDF documents.
Example: Using a select element to modify package files
<PDF result="newPackage">
	<PDF source="pkg1"/>
	<PackageFiles nameKeys="Attached File 1">
		<Watermark><StyledText><p>Draft</p></StyledText></Watermark>
	</PackageFiles>
	<PackageFiles>
		<Watermark verticalOffset="2in" replaceExisting="false">
			<StyledText><p>For Review</p></StyledText>
		</Watermark>
	</PackageFiles>
</PDF>
The PackageFiles result element exports the package files along with a descriptive XML document that provides information about each of the package files, such as the metadata and the unique, internal nameKey. This allows the files to be routed to another service before importing them into the original package or a new package. The following example illustrates this process. In the first XML file, the package files are exported to mypkg.xml, which is subsequently processed elsewhere. In the second XML file, mypkg.xml is re-imported into myPkg.
Example: Exporting, processing, and re-importing package files
<?xml version="1.0" encoding="UTF-8"?> <!-- Export package files -->
<DDX>
	<PackageFiles result="mypkg.xml">
	<PDF source="myPkg"/>
	</PackageFiles>
</DDX>
Process the individual package files elsewhere.
<?xml version="1.0" encoding="UTF-8"?> <!-- Import package files -->
<DDX>
	<PDF result="myPkg">
		<PDF source="myPkg"/>
		<PackageFiles import="mypkg.xml"/>
	</PDF>
</DDX>
In the example below, a new package is created. The pages from single1 become the cover sheet for resultDoc, and documents doc2 and doc3 are added as package files. The InitialViewProfile element "letterCollection",which contains the package specification, determines how the document is to be viewed when opened by the associated viewing application:
Example: Creating a new PDF package
<DDX>
	<PDF result="resultDoc" initialView="letterCollection">
		<Package styleReference="letterCollection" />
		<PDF source="single1"/>
		<PackageFiles source="doc2">
			<File filename="/documents/data" mimetype="application/pdf"/>
			<Description>email from Employee B</Description>
			<FieldData name="to">Employee A</FieldData>
			<FieldData name="from">Employee B</FieldData>
			<FieldData name="date">2005-06-21T09:47:00Z</FieldData>
			<FieldData name="subject" prefix="Re:">Lunch on Friday!</FieldData>
		</PackageFiles >
		<PackageFiles source="doc3">
			<File filename="/documents/data" mimetype="application/pdf"/>
			<Description>email from Employee A</Description>
			<FieldData name="to">Employee B</FieldData>
			<FieldData name="from">Employee A</FieldData>
			<FieldData name="date">2005-06-21T10:12:00Z</FieldData>
			<FieldData name="subject" prefix="Re:">Lunch on Friday!</FieldData>
		</PackageFiles >
	</PDF>
	<StyleProfile name="letterCollection">
		<Package>
			<Schema>
				<Field name="from" type="Text" />
				<Field name="to" type="Text" />
				<Field name="date" type="Date" />
				<Field name="subject" type="Text" />
				<Field name="size" type="Size" />
			</Schema >
			<DisplayOrder>
				<Field name="date"/>
				<Field name="subject"/>
				<Field name="from"/>
				<Field name="to"/>
				<Field name="size"/>
			</DisplayOrder>
			<SortOrder>
				<Field name="date" ascending="true"/>
			</SortOrder>
		</Package>
	</StyleProfile>
	<InitialViewProfile 
		name="letterCollection"
		packageInitialDocument="FirstSortedDocument"
		packageUIPane="Left"
	/>
</DDX>

 

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/assemblePDFAssembling.96.13.html