Hi Alexis, AFAIK, each implementation of an RTF reader/writer could cause different file sizes. There is nothing in the spec that specifies whether or not to include opitonal keywords. Some RTF writers include control words that are the default values making the file sizes larger. Some RTF Writers do not.
Also when it comes to images, RTF format supports EMF, PNG, JPEG, QuickDraw, OS2 Metafile, dib bitmap, Windows Device dependent bitmap, and windows metafile (not sure, I may have missed one). The image format used in the original file is not guarenteed to be the same format when the file is created with a different writer. I do not know what format is generated by each version of Word though. Additionally Word includes alot of default control word information, alternate tags, etc. and generates a larger file. Regards, Howard ----- Original Message ---- From: Alexis Pigeon <[EMAIL PROTECTED]> To: Post all your questions about iText here <[email protected]> Sent: Thursday, November 15, 2007 6:06:07 AM Subject: [iText-questions] [RTF] Size of iText-generated RTF file growing after saving in Word Hi all, I'm using iText 2.0.6 to generate an RTF file that has to be edited manually afterwards with Word. The problem is that, after editing, the file size is 10 times bigger than the original one. Here's a stripped-down example : public static void main(String[] args) throws Exception { FileOutputStream fos = new FileOutputStream("C:/Temp/itext/test.rtf"); Document document = new Document(); RtfWriter2.getInstance(document, fos); Table tableHeader = new Table(1); tableHeader.setBorder(0); tableHeader.getDefaultLayout().setBorder(0); tableHeader.setWidth(100); tableHeader.addCell(new Cell(Image.getInstance("C:/Temp/itext/test.jpeg"))); document.setHeader(new RtfHeaderFooter(tableHeader)); document.open(); for (int i = 0; i < 25; i++) { document.add(new Phrase("Lorem Ipsum ")); document.newPage(); } document.close(); } In this example, the Image class is com.lowagie.text.Image, and test.jpeg is attached to this mail. In case it doesn't make it through the sourceforge list filter, I got the image from [1]. If you run the example, you'll get a 13Kb file. Open it (I tried with Word97, Word2000 and OpenOffice.org 2.3), edit the content by adding just a single character, and save it. You get a 150+ Kb file! And in our real-life implementation, the original file size is 250 Kb, making 2.5 Mb file after editing. Adding a String instead of an Image in the header results in a much smaller generated file of course, but after editing it the file size is far from growing that much. I guess it's related to the different ways pictures in headers are managed in iText and Word, but I wanted to know if there would be some tweak or parameter I could set with iText to force Word to do it the "iText-way". Anyway, thanks again for the great library! Regards, alexis [1] : http://itext.ugent.be/img/lowagie_3d.jpg ____________________________________________________________________________________ Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how. http://overview.mail.yahoo.com/ ------------------------------------------------------------------------- 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 [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
