Hi all, I have also modified RtfElement.TWIPS_FACTOR and set it to 15 instead of 20. The reason is simply, Microsoft Word 2000 does it like this.
In particular when you save a rtf using Word, you'll see that the values of \picwgoal and \pichgoal are respectively the width in pixel of image * 15 and the height in pixel of image * 15. Also in Wikipedia is stated that 15 twips equals to 1 pixel. From MSDN \picwgoalN is the desired width of the picture in twips and so the formula is easy. Other question [RTF does not support GIF] I saw that Word for GIF use the control word \pngblip (in fact also png supports trasparency). And so I have simply added the support of GIF to RTF writing that control word when I have to add a GIF to the document and the game is done ;-) Now RTF supports GIF, certainly with trasparency. Bye, Raffaele -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Mark Hall Sent: lunedì 14 maggio 2007 23.13 To: Thomas Bickel Cc: [email protected] Subject: Re: [iText-questions] scaleToFit() rtf problem On Monday 14 May 2007, Thomas Bickel wrote: > isn't it the other way round? 1px = .75pt? Yes, you are right of course. > So I was correct and the rtf image resolution is 33% higher than the > document resolution. :) This is a bit annoying though because it differs > from the way the pdf writer works (where the above code sample works as > intended) and because none of the methods actually specify the units that > are used. > > The scaling is still broken however. > Check out the following example: Scaling to 99.99% in iText causes the > image to be scaled to 130% in Word while scaling to 75% causes it to be > scaled to 100%. This would work if the twips value > (RtfElement.TWIPS_FACTOR) used to convert image pixels to twips > (\picwgoal,\pichgoal) was set to 15. Yes you are correct. Sorry for being a bit slow on the uptake :-). I hadn't run the example with the PdfWriter to see what it looks like there. The problem is that the RtfWriter2 applies different metrics depending on whether you scale the image or not. An unscaled image is added at the native resolution employed by the RTF viewer (96dpi instead of the PDF 72dpi), while for scaled images the behaviour of the PdfWriter is imitated (72dpi). The question now is which way to change the RtfImage class. Should it always generate 96dpi native images, which means that the user will have to manually adjust it down to 72dpi for PDF equality. The other option is always scaling images to 72dpi, with the side-effect that all unscaled images in Word say that they are at a scale of 133%. I think that the second solution is better, due to the improved consistency between PDF and RTF, but I'm interested in other people's input here. Greetings, Mark -- Q: What do you say to a New Yorker with a job? A: Big Mac, fries and a Coke, please! My GPG public key is available at: http://www.edu.uni-klu.ac.at/~mhall/data/security/MarkHall.asc ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ 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/
