I am copying an image from clipboard and then transfering it to the rtf file
using itext, but I am getting the following exception:

com.lowagie.text.DocumentException: Only BMP, PNG, WMF, GIF and JPEG images
are supported by the RTF Writer
        at com.lowagie.text.rtf.graphic.RtfImage.<init>(Unknown Source)
        at com.lowagie.text.rtf.RtfMapper.mapElement(Unknown Source)
        at com.lowagie.text.rtf.RtfWriter2.add(Unknown Source)
        at com.lowagie.text.Document.add(Unknown Source)


// code for getting the image from the clipboard

Transferable tf=clpb.getContents(this);


    try{
    if (tf.isDataFlavorSupported(DataFlavor.imageFlavor)) {
        img1 = (java.awt.Image)tf.getTransferData(DataFlavor.imageFlavor);


            jLabel5.setIcon(new
ImageIcon(img1.getScaledInstance(jLabel5.getWidth(), jLabel5.getHeight(),
Image.SCALE_SMOOTH)));
            System.out.println("Image pasted");
                 } else {
                    System.err.println("No image data in the system
clipboard.");
                }
     }catch(Exception ex){
        JOptionPane.showMessageDialog(null, "Oh s***!!! There seems to be a
problem with the network connection./n Try again dear!");
     }

//code for adding images to itext

outputPath=jTextField2.getText()+'/';
                folder=jTextField1.getText()+'/';

                com.lowagie.text.rtf.RtfWriter2.getInstance(document, new
FileOutputStream(outputPath+folder+"8 Pics.rtf"));
                document.open();
                com.lowagie.text.Font font1 = new
com.lowagie.text.Font(com.lowagie.text.Font.HELVETICA, 15, Font.BOLD);
                com.lowagie.text.Paragraph header= new
com.lowagie.text.Paragraph("Pics Claim# "+jTextField1.getText(), font1);
                header.setAlignment(com.lowagie.text.Paragraph.ALIGN_LEFT);

                document.setHeader(new
com.lowagie.text.rtf.headerfooter.RtfHeaderFooter(header));


                com.lowagie.text.Image imgadd1 =
com.lowagie.text.Image.getInstance(img1, null);
                com.lowagie.text.Image imgadd2 =
com.lowagie.text.Image.getInstance(img2, null);
                com.lowagie.text.Image imgadd3 =
com.lowagie.text.Image.getInstance(img3, null);


                imgadd1.setAlignment(com.lowagie.text.Image.ALIGN_CENTER);
                imgadd2.setAlignment(com.lowagie.text.Image.ALIGN_CENTER);
                imgadd3.setAlignment(com.lowagie.text.Image.ALIGN_CENTER);

                document.add(imgadd1);
                document.add(imgadd2);
                document.add(imgadd3);

    }catch(Exception ex){
        ex.printStackTrace();
    }

can anyone please help help in solving my problem.........i would be
thankful
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to