diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDAbstractContentStream.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDAbstractContentStream.java index a919475fbf6..088a760ff16 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDAbstractContentStream.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDAbstractContentStream.java @@ -1674,4 +1674,40 @@ private List applyGSUBRules(GsubWorker gsubWorker, ByteArrayOutputStrea return glyphIdsAfterGsub; } + + /** + * Set the text rise value, i.e. move the baseline up or down. This is useful for drawing + * superscripts or subscripts. + * + * @param items + * @param unit_type + * @throws IllegalArgumentException + */ + public List convertUnit(List items, String unit_type) + { + float multiplier = 1; + if (unit_type == "mm") + { + multiplier = 1 / (10 * 2.54f) * 72; + } + else if (unit_type == "inch") + { + multiplier = 72; + } + else + { + throw new IllegalArgumentException( + "could not find the unit type: " + unit_type); + } + List items_new = new ArrayList(); + Iterator it = items.iterator(); + while(it.hasNext()) + { + Float item = it.next(); + item *= multiplier; + items_new.add(item); + } + + return items_new; + } }