@Test
public void createPdfAutomaticTest() throws IOException, DocumentException {

    String fileName = "xmp_metadata_automatic.pdf";
    // step 1
    Document document = new Document();
    // step 2
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(OUT_FOLDER + fileName));
    document.addTitle("Hello World example");
    document.addSubject("This example shows how to add metadata & XMP");
    document.addKeywords("Metadata, iText, step 3");
    document.addCreator("My program using 'iText'");
    document.addAuthor("Bruno Lowagie & Paulo Soares");
    writer.createXmpMetadata();
    // step 3
    document.open();
    // step 4
    document.add(new Paragraph("Hello World"));
    // step 5
    document.close();
    CompareTool ct = new CompareTool();
    Assert.assertNull(ct.compareXmp(OUT_FOLDER + fileName, CMP_FOLDER + fileName, true));
}