use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDPolygonAppearanceHandler method getLineWidth.
/**
* Get the line with of the border.
*
* Get the width of the line used to draw a border around the annotation.
* This may either be specified by the annotation dictionaries Border
* setting or by the W entry in the BS border style dictionary. If both are
* missing the default width is 1.
*
* @return the line width
*/
// TODO: according to the PDF spec the use of the BS entry is annotation
// specific
// so we will leave that to be implemented by individual handlers.
// If at the end all annotations support the BS entry this can be handled
// here and removed from the individual handlers.
float getLineWidth() {
PDAnnotationMarkup annotation = (PDAnnotationMarkup) getAnnotation();
PDBorderStyleDictionary bs = annotation.getBorderStyle();
if (bs != null) {
return bs.getWidth();
}
COSArray borderCharacteristics = annotation.getBorder();
if (borderCharacteristics.size() >= 3) {
COSBase base = borderCharacteristics.getObject(2);
if (base instanceof COSNumber) {
return ((COSNumber) base).floatValue();
}
}
return 1;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDPolylineAppearanceHandler method getLineWidth.
// TODO DRY, this code is from polygonAppearanceHandler so it's double
/**
* Get the line with of the border.
*
* Get the width of the line used to draw a border around the annotation.
* This may either be specified by the annotation dictionaries Border
* setting or by the W entry in the BS border style dictionary. If both are
* missing the default width is 1.
*
* @return the line width
*/
// TODO: according to the PDF spec the use of the BS entry is annotation
// specific
// so we will leave that to be implemented by individual handlers.
// If at the end all annotations support the BS entry this can be handled
// here and removed from the individual handlers.
float getLineWidth() {
PDAnnotationMarkup annotation = (PDAnnotationMarkup) getAnnotation();
PDBorderStyleDictionary bs = annotation.getBorderStyle();
if (bs != null) {
return bs.getWidth();
}
COSArray borderCharacteristics = annotation.getBorder();
if (borderCharacteristics.size() >= 3) {
COSBase base = borderCharacteristics.getObject(2);
if (base instanceof COSNumber) {
return ((COSNumber) base).floatValue();
}
}
return 1;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDSquareAppearanceHandler method getLineWidth.
/**
* Get the line with of the border.
*
* Get the width of the line used to draw a border around the annotation.
* This may either be specified by the annotation dictionaries Border
* setting or by the W entry in the BS border style dictionary. If both are
* missing the default width is 1.
*
* @return the line width
*/
// TODO: according to the PDF spec the use of the BS entry is annotation
// specific
// so we will leave that to be implemented by individual handlers.
// If at the end all annotations support the BS entry this can be handled
// here and removed from the individual handlers.
float getLineWidth() {
PDAnnotationMarkup annotation = (PDAnnotationMarkup) getAnnotation();
PDBorderStyleDictionary bs = annotation.getBorderStyle();
if (bs != null) {
return bs.getWidth();
}
COSArray borderCharacteristics = annotation.getBorder();
if (borderCharacteristics.size() >= 3) {
COSBase base = borderCharacteristics.getObject(2);
if (base instanceof COSNumber) {
return ((COSNumber) base).floatValue();
}
}
return 1;
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDPropBuildDataDict method setOS.
/**
* Indicates the operating system. The string format isn't specified yet. Value will be stored
* as first item of the array, as specified in PDF Signature Build Dictionary Specification for
* PDF v1.7.
*
* @param os is a string with the system id or name.
*/
public void setOS(String os) {
if (os == null) {
dictionary.removeItem(COSName.OS);
} else {
COSBase osArray = dictionary.getItem(COSName.OS);
if (!(osArray instanceof COSArray)) {
osArray = new COSArray();
osArray.setDirect(true);
dictionary.setItem(COSName.OS, osArray);
}
((COSArray) osArray).add(0, COSName.getPDFName(os));
}
}
use of com.tom_roush.pdfbox.cos.COSBase in project PdfBox-Android by TomRoush.
the class PDSeedValueCertificate method getSubjectDN.
/**
* Returns list of maps that contains subject distinguished names like [(cn: John Doe, o: Doe), (cn: John Smith)]
* both keys are typically of the form 'cn', 'o', 'email', '2.5.4.43'; and values are text strings.
*
* @return a list of maps containing the subject distinguished names
*/
public List<Map<String, String>> getSubjectDN() {
COSBase base = this.dictionary.getDictionaryObject(COSName.SUBJECT_DN);
if (base instanceof COSArray) {
COSArray cosArray = (COSArray) base;
List subjectDNList = cosArray.toList();
List<Map<String, String>> result = new LinkedList<Map<String, String>>();
for (Object subjectDNItem : subjectDNList) {
if (subjectDNItem instanceof COSDictionary) {
COSDictionary subjectDNItemDict = (COSDictionary) subjectDNItem;
Map<String, String> subjectDNMap = new HashMap<String, String>();
for (COSName key : subjectDNItemDict.keySet()) {
subjectDNMap.put(key.getName(), subjectDNItemDict.getString(key));
}
result.add(subjectDNMap);
}
}
return result;
}
return null;
}
Aggregations