wwkloo, wwkloo wrote > I am processing PDF of Asian Unicode characters. I need to get the > bounding boxes for every character inside the PDF. > > When I try to extract the bounding box using the following code, I found > that the box for a non-BMP character (the first Asian character) has zero > width. However, it is displayed properly in the PDF. > iTextExtract_W.pdf > <http://itext-general.2136553.n4.nabble.com/file/n4657896/iTextExtract_W.pdf> >
I'm afraid that both iText and iTextSharp assume the string in a TextRenderInfo object to contain only BMP characters when determining the width of that string. The relevant loop looks like this: char[] chars = str.ToCharArray(); float totalWidth = 0; for (int i = 0; i < chars.Length; i++) { float w = font.GetWidth(chars[i]) / 1000.0f; float wordSpacing = chars[i] == 32 ? gs.wordSpacing : 0f; totalWidth += (w * gs.fontSize + gs.characterSpacing + wordSpacing) * gs.horizontalScaling; } Thus, each 16-bit char is considered by itself. Maybe the code in general should be inspected for such BMP-character-assumptions. Regards, Michael -- View this message in context: http://itext-general.2136553.n4.nabble.com/Text-box-of-non-BMP-character-with-zero-width-tp4657896p4657966.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Own the Future-Intel(R) Level Up Game Demo Contest 2013 Rise to greatness in Intel's independent game demo contest. Compete for recognition, cash, and the chance to get your game on Steam. $5K grand prize plus 10 genre and skill prizes. Submit your demo by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2 _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php