Hello,

I have added some text and an image to a new RTF document, and now I
want to wrap the text around the image and align it to the right.

Image.TEXTWRAP is not working. When I change my code to PDF export, it
works right away. I believe I have tried everyting to make the text go
around the picture in RTF using TEXTWRAP in different ways.

As a last solution I changed my code to use an RtfShape, hoping that I
could add my image as an RtfShape. However, in this case I get a
NullPointerException:

Exception in thread "main" java.lang.NullPointerException
        at com.lowagie.text.rtf.graphic.RtfImage.writeContent(Unknown Source)
        at com.lowagie.text.rtf.graphic.RtfShapeProperty.writeContent(Unknown
Source)
        at com.lowagie.text.rtf.graphic.RtfShape.writeContent(Unknown Source)
        at com.lowagie.text.rtf.document.RtfDocument.add(Unknown Source)
        at com.lowagie.text.rtf.RtfWriter2.add(Unknown Source)
        at com.lowagie.text.Document.add(Unknown Source)
        at GenerateRtf.main(GenerateRtf.java:30)


Here is my code:


public static void main(String[] args) throws Exception{
  String text = "";
  for (int i = 0; i<200; i++)
    text += "ttt tt tttt ";

  Document document = new Document();
  RtfWriter2.getInstance(document,
new FileOutputStream("/home/henrik/testRTFdocument.rtf", false));
 document.open();

  Image image = Image.getInstance("/home/henrik/rtfTest.jpeg");
  RtfShapePosition position = new RtfShapePosition(3000, 6000, 10500,
4500);
  RtfShape shape = new RtfShape(
    RtfShape.SHAPE_RECTANGLE, position);
  shape.setWrapping(RtfShape.SHAPE_WRAP_LEFT);
  shape.setProperty(
    new RtfShapeProperty(RtfShapeProperty.PROPERTY_IMAGE, image));
    
  document.add(shape);
  Paragraph main = new Paragraph();
  main.add(text);
  document.add(main);
  document.close();
}

Any suggestions will be greatly appreciated!

Best regards
Henrik Otgard


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to