Check out the tutorials here. 
http://itextdocs.lowagie.com/tutorial/rtf/features/shape/index.php
 If you need further assistance, please let me know. Busy day for me, but I'll 
try to help if I can.

Howard



----- Original Message ----
From: Kianoosh Raika <[EMAIL PROTECTED]>
To: Post all your questions about iText here 
<[email protected]>
Sent: Thursday, July 17, 2008 7:14:37 PM
Subject: Re: [iText-questions] RTF Image : setting alignment and layout

Ah yes, that setting is there.

However, this RtfShape class is a bit tricky to use. Here's some unit
test code where I'm getting a NullPointerException (stack below). Am I
not setting the Image properly?  The RtfShapeProperty constructor
takes an Image, not RtfImage, and I believe I'm creating the Image
object correctly. I basically want the image to appear in the top left
corner so that's why I chose SHAPE_RECTANGLE with those coordinates.

    Document d = new Document();
    d.open();
    RtfDocument doc = new RtfDocument();

    float scale = 50;
    Image logo = Image.getInstance("webapp/images/logo.gif");
    logo.scalePercent(scale);
    logo.setAbsolutePosition(0,0);
    logo.setAlignment(Image.LEFT);
    RtfShapePosition position = new RtfShapePosition(0, 0, 200, 200);
    RtfShape shape = new RtfShape(RtfShape.SHAPE_RECTANGLE, position);
    shape.setRtfDocument(doc);
    shape.setWrapping(RtfShape.SHAPE_WRAP_NONE);
    shape.setProperty(new RtfShapeProperty(RtfShapeProperty.PROPERTY_IMAGE, 
logo));

    doc.add(shape);

    ClassPathResource clRtf = new
ClassPathResource("/com/path/to/letterhead-noimg.rtf");
    RtfParser r = new RtfParser(d);
    r.importRtfDocument(clRtf.getInputStream(), doc);
    OutputStream os = new FileOutputStream("outputfile.rtf");
    doc = r.getRtfDocument();
    doc.writeDocument(os);

gives this:

java.lang.NullPointerException
    at com.lowagie.text.rtf.graphic.RtfImage.<init>(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...DaoTest.testImportRtf(DaoTest.java:91)

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar



      


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to