Hi
On Fri, Jul 24, 2015 at 4:44 PM, Tilman Hausherr <[email protected]>
wrote:
Am 24.07.2015 um 10:27 schrieb Roberto Nibali:
>
>> 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.
>>
>
> Because it could be simpler:
>
> PDFStreamParser parser = new
> PDFStreamParser(field.getDefaultAppearance().getBytes()));
>
>
D'oh, thanks! I'll try to engage my brain a wee bit more next time.
Best regards
Roberto