By Date: <-- -->
By Thread: <-- -->

Writing text in signature appearance which doesn't get cut



Hi guys,

I am trying to write some text in a signature appearance using PDFTemplate.

          n2.beginText();
          BaseFont bf = BaseFont.createFont("Helvetica", BaseFont.WINANSI,
false);
          n2.setColorStroke(java.awt.Color.BLUE);
          n2.setFontAndSize(bf, FONT_SIZE);
          n2.setTextMatrix(10, 100);

          n2.showText("This is a very very long text so please scale this
text");
          n2.endText();

In case the signature appearance is small, the text above gets cut. I need
to set a font based on the size of the signature appearance so that the full
text is shown. One way is to find the right balance by hit and trial i.e.if
the width of the n2 is so and so then font size should be so and so if the
text size is in a particular range. This is cumbersome, I was wondering
whether there is some function which can tell me how much area a text would
take i.e. the above text if using a particular font would take 100 pixels. I
can then compare with the n2's width and if the text get cut then reduce the
font size and again check. Is there any function or way ?

Thanks for reading..

Regards,
Wahaj

Attachment: smime.p7s
Description: S/MIME cryptographic signature