AssociatedFileRelationship Enum
Specifies the relationship between an associated file and the PDF document.
Declaration
public enum AssociatedFileRelationship extends Enum<AssociatedFileRelationship> implements IIntEnum
Members
| Name | Description |
|---|---|
ALTERNATIVE
|
Specifies that the file is an alternative representation of the document content. |
DATA
|
Specifies that the file contains data associated with the document. |
ENCRYPTED_PAYLOAD
|
Specifies that the file contains encrypted payload data. |
SOURCE
|
Specifies that the file is the source for the document content. |
SUPPLEMENT
|
Specifies that the file supplements the document content. |
UNSPECIFIED
|
Specifies that the file relationship is not defined. |
fromValue(int value)
|
Returns the enum value that corresponds to the specified integer. |
getName()
|
Returns the name of this enum value. |
getValue()
|
Returns the integer value of this enum item. |
toString()
|
Returns the string representation of this enum value. |
valueOf(String name)
|
Returns the enum value with the specified name. |
values()
|
Returns an array that contains all enum values. |
Remarks
The following code snippet attaches an XML file to a PDF document and marks it as the source document:
import com.devexpress.docs.pdf.*;
import java.nio.file.*;
try (PdfDocument pdfDocument = new PdfDocument()) {
// Add an A4-size page to the document.
pdfDocument.getPages().add(DXPaperKind.A4);
Attachment attachment = new Attachment(
"invoice.xml",
Files.readAllBytes(Path.of("invoice.xml")));
// Specify the MIME type.
attachment.setMimeType("application/xml");
// Specify how the embedded file is related to the PDF document.
attachment.setRelationship(AssociatedFileRelationship.SOURCE);
// Add the attachment to the document.
pdfDocument.getAttachments().add(attachment);
// Save the document.
try (WritableByteChannel channel =
FileChannel.open(Path.of("result.pdf"),
StandardOpenOption.CREATE,
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING)) {
pdfDocument.save(channel);
}
}