use of org.apache.xmpbox.xml.DomXmpParser in project pdfbox by apache.
the class AbstractSchemaTester method before.
public void before() throws Exception {
builder = new DomXmpParser();
xmp = XMPMetadata.createXMPMetadata();
typeMapping = xmp.getTypeMapping();
}
use of org.apache.xmpbox.xml.DomXmpParser in project pdfbox by apache.
the class AbstractStructuredTypeTester method before.
public void before() throws Exception {
builder = new DomXmpParser();
xmp = XMPMetadata.createXMPMetadata();
typeMapping = xmp.getTypeMapping();
}
use of org.apache.xmpbox.xml.DomXmpParser in project pdfbox by apache.
the class CreatePDFATest method testCreatePDFA.
/**
* Test of doIt method of class CreatePDFA.
*/
public void testCreatePDFA() throws Exception {
System.out.println("testCreatePDFA");
String pdfaFilename = outDir + "/PDFA.pdf";
String message = "The quick brown fox jumps over the lazy dog äöüÄÖÜß @°^²³ {[]}";
String dir = "../pdfbox/src/main/resources/org/apache/pdfbox/resources/ttf/";
String fontfile = dir + "LiberationSans-Regular.ttf";
CreatePDFA.main(new String[] { pdfaFilename, message, fontfile });
PreflightParser preflightParser = new PreflightParser(new File(pdfaFilename));
preflightParser.parse();
try (PreflightDocument preflightDocument = preflightParser.getPreflightDocument()) {
preflightDocument.validate();
ValidationResult result = preflightDocument.getResult();
for (ValidationError ve : result.getErrorsList()) {
System.err.println(ve.getErrorCode() + ": " + ve.getDetails());
}
assertTrue("PDF file created with CreatePDFA is not valid PDF/A-1b", result.isValid());
}
// check the XMP metadata
PDDocument document = PDDocument.load(new File(pdfaFilename));
PDDocumentCatalog catalog = document.getDocumentCatalog();
PDMetadata meta = catalog.getMetadata();
DomXmpParser xmpParser = new DomXmpParser();
XMPMetadata metadata = xmpParser.parse(meta.createInputStream());
DublinCoreSchema dc = metadata.getDublinCoreSchema();
assertEquals(pdfaFilename, dc.getTitle());
document.close();
}
use of org.apache.xmpbox.xml.DomXmpParser in project pdfbox by apache.
the class ExtractMetadata method main.
/**
* This is the main method.
*
* @param args The command line arguments.
*
* @throws IOException If there is an error parsing the document.
* @throws XmpParsingException
*/
public static void main(String[] args) throws IOException, XmpParsingException {
if (args.length != 1) {
usage();
System.exit(1);
} else {
try (PDDocument document = PDDocument.load(new File(args[0]))) {
PDDocumentCatalog catalog = document.getDocumentCatalog();
PDMetadata meta = catalog.getMetadata();
if (meta != null) {
DomXmpParser xmpParser = new DomXmpParser();
try {
XMPMetadata metadata = xmpParser.parse(meta.createInputStream());
DublinCoreSchema dc = metadata.getDublinCoreSchema();
if (dc != null) {
display("Title:", dc.getTitle());
display("Description:", dc.getDescription());
listString("Creators: ", dc.getCreators());
listCalendar("Dates:", dc.getDates());
listString("Subjects:", dc.getSubjects());
}
AdobePDFSchema pdf = metadata.getAdobePDFSchema();
if (pdf != null) {
display("Keywords:", pdf.getKeywords());
display("PDF Version:", pdf.getPDFVersion());
display("PDF Producer:", pdf.getProducer());
}
XMPBasicSchema basic = metadata.getXMPBasicSchema();
if (basic != null) {
display("Create Date:", basic.getCreateDate());
display("Modify Date:", basic.getModifyDate());
display("Creator Tool:", basic.getCreatorTool());
}
} catch (XmpParsingException e) {
System.err.println("An error ouccred when parsing the meta data: " + e.getMessage());
}
} else {
// The pdf doesn't contain any metadata, try to use the
// document information instead
PDDocumentInformation information = document.getDocumentInformation();
if (information != null) {
showDocumentInformation(information);
}
}
}
}
}
use of org.apache.xmpbox.xml.DomXmpParser in project pdfbox by apache.
the class TestXMPWithDefinedSchemas method main.
@Test
public void main() throws Exception {
InputStream is = this.getClass().getResourceAsStream(path);
DomXmpParser builder = new DomXmpParser();
XMPMetadata rxmp = builder.parse(is);
}
Aggregations