use of org.apache.xmpbox.type.TextType in project pdfbox by apache.
the class FontMetaDataValidation method analyseFontName.
/**
* Value of the dc:title must be the same as the FontName in the font descriptor.
*
* @param metadata
* XMPMetaData of the Font File Stream
* @param fontDesc
* The FontDescriptor dictionary
* @param ve
* the list of validation error to update if the validation fails
*/
public boolean analyseFontName(XMPMetadata metadata, PDFontDescriptor fontDesc, List<ValidationError> ve) {
String fontName = fontDesc.getFontName();
String noSubSetName = fontName;
if (FontDescriptorHelper.isSubSet(fontName)) {
noSubSetName = fontName.split("\\+")[1];
}
DublinCoreSchema dc = metadata.getDublinCoreSchema();
if (dc != null && dc.getTitleProperty() != null) {
String defaultTitle = dc.getTitle("x-default");
if (defaultTitle != null) {
if (!defaultTitle.equals(fontName) && (noSubSetName != null && !defaultTitle.equals(noSubSetName))) {
StringBuilder sb = new StringBuilder(80);
sb.append("FontName").append(" present in the FontDescriptor dictionary doesn't match with XMP information dc:title of the Font File Stream.");
ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_MISMATCH, sb.toString()));
return false;
}
// --- default value is the right one
return true;
} else {
Iterator<AbstractField> it = dc.getTitleProperty().getContainer().getAllProperties().iterator();
boolean empty = true;
while (it.hasNext()) {
empty = false;
AbstractField tmp = it.next();
if (tmp instanceof TextType) {
String val = ((TextType) tmp).getStringValue();
if (val.equals(fontName) || val.equals(noSubSetName)) {
// value found, return
return true;
}
}
}
// title doesn't match, it is an error.
StringBuilder sb = new StringBuilder(80);
sb.append("FontName");
if (empty) {
sb.append(" present in the FontDescriptor dictionary can't be found in XMP information the Font File Stream.");
ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_PROPERTY_MISSING, sb.toString()));
} else {
sb.append(" present in the FontDescriptor dictionary doesn't match with XMP information dc:title of the Font File Stream.");
ve.add(new ValidationError(PreflightConstants.ERROR_METADATA_MISMATCH, sb.toString()));
}
return false;
}
}
return true;
}
use of org.apache.xmpbox.type.TextType in project pdfbox by apache.
the class AdobePDFSchema method setKeywords.
/**
* Set the PDF keywords
*
* @param value
* Value to set
*/
public void setKeywords(String value) {
TextType keywords;
keywords = createTextType(KEYWORDS, value);
addProperty(keywords);
}
use of org.apache.xmpbox.type.TextType in project pdfbox by apache.
the class PDFAIdentificationSchema method setConformance.
/**
* Set the PDF/A conformance level
*
* @param value
* The conformance level value to set
* @throws BadFieldValueException
* If Conformance Value not 'A', 'B' or 'U' (PDF/A-2 and PDF/A-3)
*/
public void setConformance(String value) throws BadFieldValueException {
if (value.equals("A") || value.equals("B") || value.equals("U")) {
TextType conf = createTextType(CONFORMANCE, value);
addProperty(conf);
} else {
throw new BadFieldValueException("The property given not seems to be a PDF/A conformance level (must be A, B or U)");
}
}
use of org.apache.xmpbox.type.TextType in project pdfbox by apache.
the class PhotoshopSchema method setTransmissionReference.
public void setTransmissionReference(String text) {
TextType tt = (TextType) instanciateSimple(TRANSMISSION_REFERENCE, text);
setTransmissionReferenceProperty(tt);
}
use of org.apache.xmpbox.type.TextType in project pdfbox by apache.
the class PhotoshopSchema method setCategory.
public void setCategory(String text) {
TextType tt = (TextType) instanciateSimple(CATEGORY, text);
setCategoryProperty(tt);
}
Aggregations