<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
<document> 
  <header> 
    <title>PDFBox - PDF Metadata</title> 
    <meta name="keywords">Java PDF Library, XMP, PDF metadata, pdfbox</meta>
  </header> 
  <body> 
    <section>
      <title>Accessing Metadata</title>
      <p>
      See class:<a href="../javadoc/org/pdfbox/pdmodel/common/PDMetadata.html">org.pdfbox.pdmodel.common.PDMetadata</a> <br/>
      See example:<a href="../javadoc/org/pdfbox/examples/pdmodel/AddMetadataFromDocInfo.html">AddMetadataFromDocInfo</a> <br/>
      See Adobe Documentation:<a href="http://partners.adobe.com/public/developer/en/xmp/sdk/xmpspecification.pdf">XMP Specification</a>
      </p>
      <p>
      	PDF documents can have XML metadata associated with certain objects within a PDF document.  For example, the following PD Model objects
      	have the ability to contain metadata:
     </p>
  	 <ul>
  	    <li>PDDocumentCatalog</li>
        <li>PDPage</li>
        <li>PDXObject</li>
        <li>PDICCBased</li>
        <li>PDStream</li>
  	 </ul>
     
     <p>The metadata that is stored in PDF objects conforms to the XMP specification, it is recommended that you review that specification.
        Currently there is no high level API for managing the XML metadata, PDFBox uses standard java InputStream/OutputStream 
        to retrieve or set the XML metadata.  For example:</p> 	
      
      <source>
      PDDocument doc = PDDocument.load( ... );
      PDDocumentCatalog catalog = doc.getDocumentCatalog();
      PDMetadata metadata = catalog.getMetadata();
      
      //to read the XML metadata
      InputStream xmlInputStream = metadata.createInputStream();
      
      //or to write new XML metadata
      InputStream newXMPData = ...;
      PDMetadata newMetadata = new PDMetadata(doc, newXMLData, false );
      catalog.setMetadata( newMetadata );
      </source>
    </section>
  </body>
</document>
