Class XmpWriter

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class XmpWriter
    extends java.lang.Object
    implements java.lang.AutoCloseable
    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.lang.String about
      The about string that goes into the rdf:Description tags.
      protected char end
      The end attribute.
      protected int extraSpace
      You can add some extra space in the XMP packet; 1 unit in this variable represents 100 spaces and a newline.
      static java.lang.String EXTRASPACE
      String used to fill the extra space.
      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 java.io.OutputStreamWriter writer
      The writer to which you can write bytes for the XMP stream.
      static java.lang.String XPACKET_PI_BEGIN
      Processing Instruction required at the start of an XMP stream
      static java.lang.String XPACKET_PI_END_R
      Processing Instruction required at the end of an XMP stream for XMP streams that are read only
      static java.lang.String XPACKET_PI_END_W
      Processing Instruction required at the end of an XMP stream for XMP streams that can be updated
    • Constructor Summary

      Constructors 
      Constructor Description
      XmpWriter​(java.io.OutputStream os)
      Creates an XmpWriter.
      XmpWriter​(java.io.OutputStream os, PdfDictionary info, int PdfXConformance)  
      XmpWriter​(java.io.OutputStream os, java.lang.String utfEncoding, int extraSpace)
      Creates an XmpWriter.
      XmpWriter​(java.io.OutputStream os, java.util.Map info)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addRdfDescription​(XmpSchema s)
      Adds an rdf:Description.
      void addRdfDescription​(java.lang.String xmlns, java.lang.String content)
      Adds an rdf:Description.
      void close()
      Flushes and closes the XmpWriter.
      void setAbout​(java.lang.String about)  
      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 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
      • EXTRASPACE

        public static final java.lang.String EXTRASPACE
        String used to fill the extra space.
        See Also:
        Constant Field Values
      • XPACKET_PI_BEGIN

        public static final java.lang.String XPACKET_PI_BEGIN
        Processing Instruction required at the start of an XMP stream
        Since:
        iText 2.1.6
        See Also:
        Constant Field Values
      • XPACKET_PI_END_W

        public static final java.lang.String XPACKET_PI_END_W
        Processing Instruction required at the end of an XMP stream for XMP streams that can be updated
        Since:
        iText 2.1.6
        See Also:
        Constant Field Values
      • XPACKET_PI_END_R

        public static final java.lang.String XPACKET_PI_END_R
        Processing Instruction required at the end of an XMP stream for XMP streams that are read only
        Since:
        iText 2.1.6
        See Also:
        Constant Field Values
      • extraSpace

        protected int extraSpace
        You can add some extra space in the XMP packet; 1 unit in this variable represents 100 spaces and a newline.
      • writer

        protected java.io.OutputStreamWriter writer
        The writer to which you can write bytes for the XMP stream.
      • about

        protected java.lang.String about
        The about string that goes into the rdf:Description tags.
      • end

        protected char end
        The end attribute.
    • Constructor Detail

      • XmpWriter

        public XmpWriter​(java.io.OutputStream os,
                         java.lang.String utfEncoding,
                         int extraSpace)
                  throws java.io.IOException
        Creates an XmpWriter.
        Parameters:
        os - output stream
        utfEncoding - utf encoding to be used
        extraSpace - extra space
        Throws:
        java.io.IOException - on error
      • XmpWriter

        public XmpWriter​(java.io.OutputStream os)
                  throws java.io.IOException
        Creates an XmpWriter.
        Parameters:
        os - output stream
        Throws:
        java.io.IOException - on error
      • XmpWriter

        public XmpWriter​(java.io.OutputStream os,
                         PdfDictionary info,
                         int PdfXConformance)
                  throws java.io.IOException
        Parameters:
        os - output stream
        info - PdfDictionary
        PdfXConformance - pdf conformance eg. values PdfWriter.PDFA1A, PdfWriter.PDFA1B
        Throws:
        java.io.IOException - on error
      • XmpWriter

        public XmpWriter​(java.io.OutputStream os,
                         java.util.Map info)
                  throws java.io.IOException
        Parameters:
        os - output stream
        info - map of info
        Throws:
        java.io.IOException - on error
    • Method Detail

      • 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

        public void addRdfDescription​(java.lang.String xmlns,
                                      java.lang.String content)
                               throws java.io.IOException
        Adds an rdf:Description.
        Parameters:
        xmlns - xml namespace
        content - content
        Throws:
        java.io.IOException - on error
      • addRdfDescription

        public void addRdfDescription​(XmpSchema s)
                               throws java.io.IOException
        Adds an rdf:Description.
        Parameters:
        s - xmp schema
        Throws:
        java.io.IOException - on error
      • close

        public void close()
                   throws java.io.IOException
        Flushes and closes the XmpWriter.
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.io.IOException - on error