Are you using the latest version 1.0?

Best Regards,
Paulo Soares

> -----Original Message-----
> From: Benny Pedersen [SMTP:[EMAIL PROTECTED]
> Sent: Tuesday, September 23, 2003 10:55
> To:   '[EMAIL PROTECTED]'
> Subject:      [iText-questions] embedding RAW images into RTF a document
> 
> Hi 
> I'm trying to create a RTF document using IText. 
> In the example below I have created two methods for embedding an image
> into
> a RTF document, but only the first one works (testLoadImage that is). I
> would like to be able to insert images in the byte[] form, since I'm
> creating the images on-the-fly.
> I hope anyone can help me.
> 
> Thanks in advance.
> 
> Benny Pedersen
> 
> 
> 
> 
> public class TestImage {
>    public static void main(String[] args) {
>       try {
>          TestImage test = new TestImage();
>          String image = "test/smurf.png";
>          test.testLoadImage(image);
>          test.testRawImage(image);
>       } catch (Exception e) {
>          e.printStackTrace();
>       }
>    }
> 
>    public void testRawImage(String imagepath) throws IOException,
> DocumentException {
>       //prefetch imagepath
>       InputStream in = getClass().getResourceAsStream(imagepath);
>       ByteArrayOutputStream bout = new ByteArrayOutputStream();
>       byte[] buffer = new byte[1024];
>       int bytesRead = 0;
>       while ((bytesRead = in.read(buffer)) > -1) {
>          bout.write(buffer, 0, bytesRead);
>       }
>       in.close();
>       byte[] rawImage  = bout.toByteArray();
> 
>       //build and save document
>       Document document = new Document();
>       OutputStream out = new FileOutputStream("out1.rtf");
>       RtfWriter.getInstance(document, out);
>       document.open();
>       Image image = Image.getInstance(rawImage);
>       document.add(image);
>       document.close();
>    }
> 
>    public void testLoadImage(String imagepath) throws IOException,
> DocumentException {
>       //build and save document
>       Document document = new Document();
>       OutputStream out = new FileOutputStream("out2.rtf");
>       RtfWriter.getInstance(document, out);
>       document.open();
>       Image image = Image.getInstance(getClass().getResource(imagepath));
>       document.add(image);
>       document.close();
>    }
> 
> }
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to