1

I'm trying to append text on an existing PDF. There is a huge text box(may be a paragraph box?) and when I try to add multiple lines of text, it's flowing out of the box. I'm doing this:

TextFragment txtFrag = new TextFragment(str);
        txtFrag .setPosition(100,200);
        txtFrag .getTextState().setFont(new FontRepository().findFont("Arial"));
        txtFrag .getTextState().setFontSize(9.0F);
TextBuilder textBuilder = new TextBuilder(page);
        textBuilder.appendText(txtFrag);

The string str in TextFragment(str) is a paragraph with multiple lines. How should I achieve text wrapping?

shakeel
  • 1,717
  • 10
  • 14
intruder
  • 417
  • 1
  • 3
  • 18

1 Answers1

3

You may set "WordWrapMode" by using below line of code:

paragraph.getFormattingOptions().setWrapMode(1);

This will keep the text inside the box. You may visit WordWrapMode Field to learn more about it. I hope this will be helpful. Please let us know if you need any further assistance.

I work with Aspose as Developer Evangelist.

Farhan Raza
  • 392
  • 1
  • 8