Hi
Until last week, the following code worked just fine:
public static String calculateFontSize(PDTextField field) throws IOException {
PDFStreamParser parser = new PDFStreamParser(new
RandomAccessBuffer(field.getDefaultAppearance().getBytes()));
parser.parse();
final List<Object> tokens = parser.getTokens();
int setFontOperatorIndex = tokens.indexOf(Operator.getOperator("Tf"));
Integer fontSize = ((COSNumber) tokens.get(setFontOperatorIndex -
1)).intValue();
/* This specifies that the text appearing on the button by default
should be Courier
8pts in size or the original size, and the color of the text is
black (0 g = 0 setgray)
*/
return "/Cour " + (fontSize == 0 ? 8 : fontSize) + " Tf 0 g";
}
Could someone maybe help me out with how the new code should be structured?
The following line:
PDFStreamParser parser = new PDFStreamParser(new
RandomAccessBuffer(field.getDefaultAppearance().getBytes()));
does not compile anymore. The simple solution is a cast:
PDFStreamParser parser = new PDFStreamParser((PDContentStream) new
RandomAccessBuffer(field.getDefaultAppearance().getBytes()));
Is this the correct approach? It looks overly twisted.
Thanks and best regards
Roberto