Package com.itextpdf.text.xml.xmp
Class XmpWriter
- java.lang.Object
-
- com.itextpdf.text.xml.xmp.XmpWriter
-
- Direct Known Subclasses:
PdfAXmpWriter
public class XmpWriter extends java.lang.Object
With this class you can create an Xmp Stream that can be used for adding Metadata to a PDF Dictionary. Remark that this class doesn't cover the complete XMP specification.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.io.OutputStream
outputStream
protected SerializeOptions
serializeOptions
static java.lang.String
UTF16
A possible charset for the XMP.static java.lang.String
UTF16BE
A possible charset for the XMP.static java.lang.String
UTF16LE
A possible charset for the XMP.static java.lang.String
UTF8
A possible charset for the XMP.protected XMPMeta
xmpMeta
-
Constructor Summary
Constructors Constructor Description XmpWriter(java.io.OutputStream os)
Creates an XmpWriter.XmpWriter(java.io.OutputStream os, PdfDictionary info)
XmpWriter(java.io.OutputStream os, java.lang.String utfEncoding, int extraSpace)
Creates an XmpWriter.XmpWriter(java.io.OutputStream os, java.util.Map<java.lang.String,java.lang.String> info)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDocInfoProperty(java.lang.Object key, java.lang.String value)
void
addRdfDescription(XmpSchema s)
Deprecated.void
addRdfDescription(java.lang.String xmlns, java.lang.String content)
Deprecated.void
appendAlternateArrayItem(java.lang.String schemaNS, java.lang.String arrayName, java.lang.String value)
Simplifies the construction of an alternate array by not requiring that you pre-create an empty array.void
appendArrayItem(java.lang.String schemaNS, java.lang.String arrayName, java.lang.String value)
Simplifies the construction of an array by not requiring that you pre-create an empty array.void
appendOrderedArrayItem(java.lang.String schemaNS, java.lang.String arrayName, java.lang.String value)
Simplifies the construction of an ordered array by not requiring that you pre-create an empty array.void
close()
Flushes and closes the XmpWriter.XMPMeta
getXmpMeta()
void
serialize(java.io.OutputStream externalOutputStream)
Flushes and closes the XmpWriter.void
setAbout(java.lang.String about)
void
setProperty(java.lang.String schemaNS, java.lang.String propName, java.lang.Object value)
void
setReadOnly()
Sets the XMP to read-only
-
-
-
Field Detail
-
UTF8
public static final java.lang.String UTF8
A possible charset for the XMP.- See Also:
- Constant Field Values
-
UTF16
public static final java.lang.String UTF16
A possible charset for the XMP.- See Also:
- Constant Field Values
-
UTF16BE
public static final java.lang.String UTF16BE
A possible charset for the XMP.- See Also:
- Constant Field Values
-
UTF16LE
public static final java.lang.String UTF16LE
A possible charset for the XMP.- See Also:
- Constant Field Values
-
xmpMeta
protected XMPMeta xmpMeta
-
outputStream
protected java.io.OutputStream outputStream
-
serializeOptions
protected SerializeOptions serializeOptions
-
-
Constructor Detail
-
XmpWriter
public XmpWriter(java.io.OutputStream os, java.lang.String utfEncoding, int extraSpace) throws java.io.IOException
Creates an XmpWriter.- Parameters:
os
-utfEncoding
-extraSpace
-- Throws:
java.io.IOException
-
XmpWriter
public XmpWriter(java.io.OutputStream os) throws java.io.IOException
Creates an XmpWriter.- Parameters:
os
-- Throws:
java.io.IOException
-
XmpWriter
public XmpWriter(java.io.OutputStream os, PdfDictionary info) throws java.io.IOException
- Parameters:
os
-info
-- Throws:
java.io.IOException
-
XmpWriter
public XmpWriter(java.io.OutputStream os, java.util.Map<java.lang.String,java.lang.String> info) throws java.io.IOException
- Parameters:
os
-info
-- Throws:
java.io.IOException
- Since:
- 5.0.1 (generic type in signature)
-
-
Method Detail
-
getXmpMeta
public XMPMeta getXmpMeta()
-
setReadOnly
public void setReadOnly()
Sets the XMP to read-only
-
setAbout
public void setAbout(java.lang.String about)
- Parameters:
about
- The about to set.
-
addRdfDescription
@Deprecated public void addRdfDescription(java.lang.String xmlns, java.lang.String content) throws java.io.IOException
Deprecated.Adds an rdf:Description.- Parameters:
xmlns
-content
-- Throws:
java.io.IOException
-
addRdfDescription
@Deprecated public void addRdfDescription(XmpSchema s) throws java.io.IOException
Deprecated.Adds an rdf:Description.- Parameters:
s
-- Throws:
java.io.IOException
-
setProperty
public void setProperty(java.lang.String schemaNS, java.lang.String propName, java.lang.Object value) throws XMPException
- Parameters:
schemaNS
- The namespace URI for the property. Has the same usage as in getProperty.propName
- The name of the property. Has the same usage as ingetProperty()
.value
- the value for the property (only leaf properties have a value). Arrays and non-leaf levels of structs do not have values. Must benull
if the value is not relevant.
The value is automatically detected: Boolean, Integer, Long, Double, XMPDateTime and byte[] are handled, on all othertoString()
is called.- Throws:
XMPException
- Wraps all errors and exceptions that may occur.
-
appendArrayItem
public void appendArrayItem(java.lang.String schemaNS, java.lang.String arrayName, java.lang.String value) throws XMPException
Simplifies the construction of an array by not requiring that you pre-create an empty array. The array that is assigned is created automatically if it does not yet exist. Each call to appendArrayItem() appends an item to the array.- Parameters:
schemaNS
- The namespace URI for the array.arrayName
- The name of the array. May be a general path expression, must not be null or the empty string.value
- the value of the array item.- Throws:
XMPException
- Wraps all errors and exceptions that may occur.
-
appendOrderedArrayItem
public void appendOrderedArrayItem(java.lang.String schemaNS, java.lang.String arrayName, java.lang.String value) throws XMPException
Simplifies the construction of an ordered array by not requiring that you pre-create an empty array. The array that is assigned is created automatically if it does not yet exist. Each call to appendArrayItem() appends an item to the array.- Parameters:
schemaNS
- The namespace URI for the array.arrayName
- The name of the array. May be a general path expression, must not be null or the empty string.value
- the value of the array item.- Throws:
XMPException
- Wraps all errors and exceptions that may occur.
-
appendAlternateArrayItem
public void appendAlternateArrayItem(java.lang.String schemaNS, java.lang.String arrayName, java.lang.String value) throws XMPException
Simplifies the construction of an alternate array by not requiring that you pre-create an empty array. The array that is assigned is created automatically if it does not yet exist. Each call to appendArrayItem() appends an item to the array.- Parameters:
schemaNS
- The namespace URI for the array.arrayName
- The name of the array. May be a general path expression, must not be null or the empty string.value
- the value of the array item.- Throws:
XMPException
- Wraps all errors and exceptions that may occur.
-
serialize
public void serialize(java.io.OutputStream externalOutputStream) throws XMPException
Flushes and closes the XmpWriter.- Throws:
java.io.IOException
XMPException
-
close
public void close() throws java.io.IOException
Flushes and closes the XmpWriter.- Throws:
java.io.IOException
-
addDocInfoProperty
public void addDocInfoProperty(java.lang.Object key, java.lang.String value) throws XMPException
- Throws:
XMPException
-
-