public class PDFAttachment
extends java.lang.Object
PDFAttachment
represents a PDF attachment.
The PDFAttachment
class defines methods to get and set the information
of an attachment.
It can be constructed by the following ways:
Example:
PDFAttachment pdfAttachment = PDFAttachment.create(PDFDocument);
PDFAttachment pdfAttachment = PDFAttachments.getAttachment(int);
PDFAttachment pdfAttachment = FileAttachment.getAttachment();
Modifier and Type | Method and Description |
---|---|
static PDFAttachment |
create(PDFDocument document)
Create a
PDFAttachment object. |
int[] |
getCheckSum()
Get checksum of the
PDFAttachment object. |
DateTime |
getCreationDateTime()
Get the created
DateTime object of an attachment. |
java.lang.String |
getDescription()
Get description of the
PDFAttachment object. |
java.lang.String |
getFileName()
Get file name of the
PDFAttachment object. |
long |
getHandle()
Get the handle of
PDFAttachment object. |
DateTime |
getModifiedDateTime()
Get the last modified
DateTime object of the PDFAttachment . |
long |
getSize()
Get the size of the
PDFAttachment object. |
boolean |
isEmbedded()
Check whether the
PDFAttachment object is an embedded file
or not. |
void |
release()
Release a
PDFAttachment object. |
void |
setCheckSum(int[] checkSum)
Set the checksum of the
PDFAttachment object. |
void |
setCreationDateTime(DateTime date)
Set the creation date of the
PDFAttachment
object. |
void |
setDescription(java.lang.String description)
Set the description of the
PDFAttachment object. |
void |
setFile(FileHandler file)
Set the file of an attachment.
|
void |
setFileName(java.lang.String fileName,
boolean bURL)
Set the file name of the
PDFAttachment object. |
void |
setModifiedDateTime(DateTime date)
Set the modification date of the
PDFAttachment . |
void |
writeToFile(FileHandler file)
Write the attachment to a file.
|
public long getHandle()
PDFAttachment
object.PDFAttachment
object.public static PDFAttachment create(PDFDocument document) throws PDFException
PDFAttachment
object.
When create a new PDFAttachment
object, function
or
setFile(FileHandler)
should be
called first to initialize attachment object before setting other
properties of it.setFileName(String, boolean)
document
- A PDFDocument
object which is a PDF document
object. It should be valid.PDFAttachment
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFDocument
public void release() throws PDFException
PDFAttachment
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean isEmbedded() throws PDFException
PDFAttachment
object is an embedded file
or not.
The PDF attachment can take either of two forms.
boolean
value that indicates whether the
attachment is an embedded file or not.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setFileName(java.lang.String fileName, boolean bURL) throws PDFException
PDFAttachment
object.
For PDFAttachment
object created by function
, this function is
used to initialize the create(PDFDocument)
PDFAttachment
object newly created
before setting other properties of it. For PDFAttachment
got
from PDF document, this function is used to set new file name to this
attachment.
ATTENTION: for initializing PDFAttachment
object newly created,
only need to call one of functions:
and
setFileName(String, boolean)
.setFile(FileHandler)
fileName
- A String
object which specifies file name of the
attachment.bURL
- A boolean
value that specifies whether the set
filename is a remote file or not.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public java.lang.String getFileName() throws PDFException
PDFAttachment
object.String
object to indicate the file name of current
PDFAttachment
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setDescription(java.lang.String description) throws PDFException
PDFAttachment
object.
Descriptive text associated with the attachment. It is used for files in
the EmbeddedFiles name tree.For "FileAttachment" annotations, viewer
applications should call
function
to set the descriptive text relating to the attached file.Annot.setContents(String)
description
- Specifies the description of the attachment.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
Annot
public java.lang.String getDescription() throws PDFException
PDFAttachment
object.
Get descriptive text associated with the attachment. It is used for files in the EmbeddedFiles name tree.
String
object that indicates the description of the
attachment.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public long getSize() throws PDFException
PDFAttachment
object.
The size of embedded attachment(in bytes).
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setCheckSum(int[] checkSum) throws PDFException
PDFAttachment
object.
The checksum is calculated by applying the standard MD5 message-digest
algorithm
(described in Internet RFC 1321, the MD5 Message-Digest
Algorithm; see the Bibliography) to the bytes of the embedded file
stream.
checkSum
- Specifies the checksum of the attachment.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public int[] getCheckSum() throws PDFException
PDFAttachment
object.
The checksum refers to checksum of the bytes of an uncompressed embedded
file.
The checksum is calculated by applying the standard MD5 message-digest
algorithm (described in Internet RFC 1321, the MD5 Message-Digest
Algorithm; see the Bibliography) to the bytes of the embedded file
stream.
integer
value array including checksum of the
attachment.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public void setCreationDateTime(DateTime date) throws PDFException
PDFAttachment
object. The creation date represents when the attachment was created.date
- The DateTime
object specifies the creation date.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
DateTime
public DateTime getCreationDateTime() throws PDFException
DateTime
object of an attachment.DateTime
object including the date time of
attachment creation.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
DateTime
public void setModifiedDateTime(DateTime date) throws PDFException
PDFAttachment
. The
modification date represents when the attachment was last modified.date
- The DateTime
object specifies the modification date.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
DateTime
public DateTime getModifiedDateTime() throws PDFException
DateTime
object of the PDFAttachment
.DateTime
object including the date and time of
attachment modification.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
DateTime
public void setFile(FileHandler file) throws PDFException
For attachment created by function
, this function is
used to initialize the newly created attachment object before setting
other properties of it. For attachment got from PDF document, this
function is used to set new file object to this attachment. create(PDFDocument)
ATTENTION: for initializing newly created attachment, only need to call
one of functions:
and
setFileName(String, boolean)
.setFile(FileHandler)
file
- A FileHandler
object, specifies the embedded
file.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FileHandler
public void writeToFile(FileHandler file) throws PDFException
file
- A FileHandler
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
FileHandler