com.itextpdf.text.xml.xmp
Class XmpWriter

java.lang.Object
  extended by com.itextpdf.text.xml.xmp.XmpWriter

public class XmpWriter
extends 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
protected  OutputStream outputStream
           
protected  SerializeOptions serializeOptions
           
static String UTF16
          A possible charset for the XMP.
static String UTF16BE
          A possible charset for the XMP.
static String UTF16LE
          A possible charset for the XMP.
static String UTF8
          A possible charset for the XMP.
protected  XMPMeta xmpMeta
           
 
Constructor Summary
XmpWriter(OutputStream os)
          Creates an XmpWriter.
XmpWriter(OutputStream os, Map<String,String> info)
           
XmpWriter(OutputStream os, PdfDictionary info)
           
XmpWriter(OutputStream os, String utfEncoding, int extraSpace)
          Creates an XmpWriter.
 
Method Summary
 void addDocInfoProperty(Object key, String value)
           
 void addRdfDescription(String xmlns, String content)
          Deprecated. 
 void addRdfDescription(XmpSchema s)
          Deprecated. 
 void appendAlternateArrayItem(String schemaNS, String arrayName, String value)
          Simplifies the construction of an alternate array by not requiring that you pre-create an empty array.
 void appendArrayItem(String schemaNS, String arrayName, String value)
          Simplifies the construction of an array by not requiring that you pre-create an empty array.
 void appendOrderedArrayItem(String schemaNS, String arrayName, 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(OutputStream externalOutputStream)
          Flushes and closes the XmpWriter.
 void setAbout(String about)
           
 void setProperty(String schemaNS, String propName, Object value)
           
 void setReadOnly()
          Sets the XMP to read-only
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8

public static final String UTF8
A possible charset for the XMP.

See Also:
Constant Field Values

UTF16

public static final String UTF16
A possible charset for the XMP.

See Also:
Constant Field Values

UTF16BE

public static final String UTF16BE
A possible charset for the XMP.

See Also:
Constant Field Values

UTF16LE

public static final String UTF16LE
A possible charset for the XMP.

See Also:
Constant Field Values

xmpMeta

protected XMPMeta xmpMeta

outputStream

protected OutputStream outputStream

serializeOptions

protected SerializeOptions serializeOptions
Constructor Detail

XmpWriter

public XmpWriter(OutputStream os,
                 String utfEncoding,
                 int extraSpace)
          throws IOException
Creates an XmpWriter.

Parameters:
os -
utfEncoding -
extraSpace -
Throws:
IOException

XmpWriter

public XmpWriter(OutputStream os)
          throws IOException
Creates an XmpWriter.

Parameters:
os -
Throws:
IOException

XmpWriter

public XmpWriter(OutputStream os,
                 PdfDictionary info)
          throws IOException
Parameters:
os -
info -
Throws:
IOException

XmpWriter

public XmpWriter(OutputStream os,
                 Map<String,String> info)
          throws IOException
Parameters:
os -
info -
Throws:
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(String about)
Parameters:
about - The about to set.

addRdfDescription

@Deprecated
public void addRdfDescription(String xmlns,
                                         String content)
                       throws IOException
Deprecated. 

Adds an rdf:Description.

Parameters:
xmlns -
content -
Throws:
IOException

addRdfDescription

@Deprecated
public void addRdfDescription(XmpSchema s)
                       throws IOException
Deprecated. 

Adds an rdf:Description.

Parameters:
s -
Throws:
IOException

setProperty

public void setProperty(String schemaNS,
                        String propName,
                        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 in getProperty().
value - the value for the property (only leaf properties have a value). Arrays and non-leaf levels of structs do not have values. Must be null if the value is not relevant.
The value is automatically detected: Boolean, Integer, Long, Double, XMPDateTime and byte[] are handled, on all other toString() is called.
Throws:
XMPException - Wraps all errors and exceptions that may occur.

appendArrayItem

public void appendArrayItem(String schemaNS,
                            String arrayName,
                            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(String schemaNS,
                                   String arrayName,
                                   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(String schemaNS,
                                     String arrayName,
                                     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(OutputStream externalOutputStream)
               throws XMPException
Flushes and closes the XmpWriter.

Throws:
IOException
XMPException

close

public void close()
           throws IOException
Flushes and closes the XmpWriter.

Throws:
IOException

addDocInfoProperty

public void addDocInfoProperty(Object key,
                               String value)
                        throws XMPException
Throws:
XMPException


Copyright © 2014. All Rights Reserved.