Sorry maybe I have overlooked the setAbsolutePosition line.. What I would like to do is actually to place an image within a rectangle area which has an absolute position and certain scale fit. FYI, the rectange is not visible and just a virtual area.
Example: Details of the rectangle ---------------------------------- jpg.setAbsolutePosition(10, 363); jpg.scaleToFit(379, 148); Since the rectangle area will start at a position (10,363) and has a width of 379, 148 height, I will need to put an image within the 379 width. The problem is the image could be of any sizes and I am not able to use apply math to fix the centre coordinate. Let say if the image is 190 width x 145 height, by right it suppose to be shifted at position (95,363) so the image would be alligned centre then. How am I possible to do that? Daniel Budde wrote: > > If I am understanding your code correctly, you are absolute positioning > your > image. How do you expect to be able to align it if you are setting it's > position absolutely? > > Daniel Budde > > -----Original Message----- > From: flyers [mailto:[email protected]] > Sent: Tuesday, July 21, 2009 5:44 AM > To: [email protected] > Subject: [iText-questions] Image.MIDDLE fails > > > Hello, > > I have problem to center the image. It keeps alligning the image on the > left > side. Below are portion of the codes. Any help would be appreciated. > > try { > > switch (pageNum) { > case 1: > textllx = 10; > textlly = 292; > texturx = 385; > textury = 312; > text2llx = 10; > text2lly = 312; > text2urx = 385; > if (extendTxt == 0) > { > text2ury = 360; > > //picx = 100; > picx = 10; > //Nurul: End of change > picy = 363; > } > else > { > text2ury = 512; > } > break; > case 2: > textllx = 400; > textlly = 292; > texturx = 775; > textury = 312; > text2llx = 400; > text2lly = 312; > text2urx = 775; > if (extendTxt == 0) > { > text2ury = 360; > //picx = 488; > > picx = 397; > //Nurul: End of change > picy = 363; > } > else > { > text2ury = 512; > } > break; > case 3: > textllx = 10; > textlly = 61; > texturx = 385; > textury = 81; > text2llx = 10; > text2lly = 80; > text2urx = 385; > if (extendTxt == 0) > { > text2ury = 130; > > //picx = 100; > picx = 10; > > picy = 131; > } > else > { > text2ury = 282; > } > break; > case 4: > textllx = 400; > textlly = 61; > texturx = 775; > textury = 81; > text2llx = 400; > text2lly = 80; > text2urx = 775; > if (extendTxt == 0) > { > text2ury = 130; > > //picx = 488; > picx = 397; > > picy = 131; > } > else > { > text2ury = 282; > } > break; > > > } > > BaseFont bf = BaseFont.createFont(BaseFont.COURIER, > BaseFont.CP1252, BaseFont.NOT_EMBEDDED); > Font font = new Font(bf, 8, Font.NORMAL); > Font font2 = new Font(bf, 8, Font.NORMAL); > if (txt_color == 1) > { > font.setColor(Color.BLUE); > } > font2.setColor(Color.BLUE); > > Phrase testText = new Phrase(0, dirText2, font2); > ColumnText ct = new ColumnText(cb); > ct.setSimpleColumn(testText, textllx, textlly, texturx, textury, > 10, > Element.ALIGN_LEFT); > ct.go(); > > Phrase testText2 = new Phrase(0, dirText, font); > ColumnText ct2 = new ColumnText(cb); > ct2.setSimpleColumn(testText2, text2llx, text2lly, text2urx, > text2ury, 10, Element.ALIGN_LEFT); > ct2.go(); > > if (extendTxt == 0) > { > Image jpg = Image.getInstance(imgFile); > jpg.setAbsolutePosition(picx, picy); > jpg.scaleToFit(379, 148); > jpg.setAlignment(Image.MIDDLE); > //Nurul: End of change > underCB.addImage(jpg); > } > -- > View this message in context: > http://www.nabble.com/Image.MIDDLE-fails-tp24585436p24585436.html > Sent from the iText - General mailing list archive at Nabble.com. > > > ---------------------------------------------------------------------------- > -- > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited time, > vendors submitting new applications to BlackBerry App World(TM) will have > the opportunity to enter the BlackBerry Developer Challenge. See full > prize > > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > 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/ > > > > ------------------------------------------------------------------------------ > Enter the BlackBerry Developer Challenge > This is your chance to win up to $100,000 in prizes! For a limited time, > vendors submitting new applications to BlackBerry App World(TM) will have > the opportunity to enter the BlackBerry Developer Challenge. See full > prize > details at: http://p.sf.net/sfu/Challenge > _______________________________________________ > 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/ > > -- View this message in context: http://www.nabble.com/Image.MIDDLE-fails-tp24585436p24601488.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ _______________________________________________ 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/
