use of org.apache.xmpbox.type.TypeMapping in project pdfbox by apache.
the class PdfaExtensionHelper method populateSchemaMapping.
public static void populateSchemaMapping(XMPMetadata meta) throws XmpParsingException {
List<XMPSchema> schems = meta.getAllSchemas();
TypeMapping tm = meta.getTypeMapping();
StructuredType stPdfaExt = PDFAExtensionSchema.class.getAnnotation(StructuredType.class);
for (XMPSchema xmpSchema : schems) {
if (xmpSchema.getNamespace().equals(stPdfaExt.namespace())) {
// ensure the prefix is the preferred one (cannot use other definition)
if (!xmpSchema.getPrefix().equals(stPdfaExt.preferedPrefix())) {
throw new XmpParsingException(ErrorType.InvalidPrefix, "Found invalid prefix for PDF/A extension, found '" + xmpSchema.getPrefix() + "', should be '" + stPdfaExt.preferedPrefix() + "'");
}
// create schema and types
PDFAExtensionSchema pes = (PDFAExtensionSchema) xmpSchema;
ArrayProperty sp = pes.getSchemasProperty();
for (AbstractField af : sp.getAllProperties()) {
if (af instanceof PDFASchemaType) {
populatePDFASchemaType(meta, (PDFASchemaType) af, tm);
}
// TODO unmanaged ?
}
}
}
}
use of org.apache.xmpbox.type.TypeMapping in project pdfbox by apache.
the class TestExifXmp method testGenerate.
@Test
public void testGenerate() throws Exception {
XMPMetadata metadata = XMPMetadata.createXMPMetadata();
TypeMapping tmapping = metadata.getTypeMapping();
ExifSchema exif = new ExifSchema(metadata);
metadata.addSchema(exif);
OECFType oecf = new OECFType(metadata);
oecf.addProperty(tmapping.createInteger(oecf.getNamespace(), oecf.getPrefix(), OECFType.COLUMNS, 14));
oecf.setPropertyName(ExifSchema.OECF);
exif.addProperty(oecf);
XmpSerializer serializer = new XmpSerializer();
serializer.serialize(metadata, new ByteArrayOutputStream(), false);
}
Aggregations