Hi Paulo,

I have tried the fitText() method but it is giving me a bigger font size
probably because of the fact that the text I am writing can be fit in the
complete signature appearance but as I am not wrapping my text there for it
still get cut at times. I believe that for this columnText would come to
rescue. Earlier I was trying the following code.


          n2.beginText();
          bf = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
          n2.setColorStroke(java.awt.Color.BLUE);
          n2.setFontAndSize(bf, f_font);                              //
This font is calculated via the fitText
          n2.setTextMatrix(f_font, f_TextYLocation);
          n2.showText(a_strDisplayLabels[i]+a_strDisplayText[i]);
          n2.endText();
          f_TextYLocation -= TEXTLINE_DIFFERENCE; //move the Y down so that
the next text could be written

In the above all of the lines are write manually which is cumbersome. Also
the text get cut even if the font is generated from fitText().

I have seen the code in irregular.java where columnText is used which wraps
automatically plus new line can be added via '\n' which is not possible via
n2.showText. Now I am trying
to get the Pdfcontent from the n2 layer and then adding the text to resolve
the wrapping issue.

        bf = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
       PdfContentByte cb = n2.getDuplicate();
       Phrase ph = new Phrase("Hello");
       ColumnText ct2 = new ColumnText(cb);
       cb.setFontAndSize(bf,16);
       ct2.setSimpleColumn(ph, 0, n2.getHeight(), n2.getWidth(), 300, 16,
Element.ALIGN_JUSTIFIED);
       ct2.setExtraParagraphSpace(5);
       ct2.go();

Using the above lines of code no text is added in the signature appearance.
Am I doing some thing wrong here ? Once the above works I will try to use
the fit text to get the correct font size.

Regards
Wahaj

"Wahaj Khan" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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

Reply via email to