BTW:
image.scaleToFit(15f, 30f); or image.scalePercent(1.0f);
doesn't work!
Dirk
-------- Original-Nachricht -------- Datum: Fri, 10 Nov 2006 09:43:14 +0100 Von: "Dirk Ulrich" <[EMAIL PROTECTED]> An: itext-questions@lists.sourceforge.net Betreff: [iText-questions] Images in Header
I am now creating a header using onEndPage. I created a Table, convert it to a PdfPTable and display it using the onEndPage method. This works fine but when I add an image (a GIF) to the table it is upscaled so that the rows height takes a third of the whole A4 page. How can I display the image in its original size?
Here's the method to create the Table:
protected Table initHeader() { // Header information String milestoneNameX = manager.getMilestoneName(data.getDataContainer().getTemplate().getMilestone().getMilestoneId().intValue()).getMilestoneNamex().toString(
) ; String milestoneAddition = data.getDataContainer().getMilestoneAddition().getMilestoneAddition().toString(); String customer = data.getDataContainer().getProject().getCustomer().getCustomerName().toString(); String projectTitle = data.getDataContainer().getProject().getProjectTitle(); StringBuffer project = new StringBuffer("Project ("); project.append(data.getDataContainer().getProject().g
et ProjectId()) .append(") \n") .append(projectTitle);
//Header for every Page : Table headTable = null; try { headTable = new Table(3); } catch (BadElementException e) { // Only thrown if a table with less than 1 column shall be created. } headTable.setWidth(100f); headTable.setPadding(3); headTable.setBorderWidth(0);
floa t[] widths = {25f, 50f, 25f}; try { headTable.setWidths(widths); } catch (BadElementException e) { // TODO Auto-generated catch block e.printStackTrace(); }
int headTableFontsize = 9; Font headerFont = FontFactory.getFont(FontFactory.HELVETICA, headTableFontsize, Font.BOLD); Paragraph msNamePhrase = new Paragraph("Milestone " + milestoneNameX + " " + milestoneAddition, headerFont); Paragraph customerPhrase = new Paragraph("Customer " + customer, headerFont); //headerFont = FontFactory.getFont(FontFactory.HELVETICA, headTableFontsize, Font.BOLD, Color.RED); Chunk projectChunk = new Chunk(project.toString(), headerFont); Paragraph projectPhrase = new Paragraph(projectChunk); Paragraph[] headerPhrases = new Paragraph[]{msNamePhrase, customerPhrase, projectPhrase};
Cell cell = null; try { //////////// Traffic light ///////////// // 1=green,2=yellow, 3=red,4=grey GifImage traffic; switch (manager.getTrafficLightColor(dataContainer,dataID)) { case 1: traffic = new GifImage(realPath + "/static/images/traffic_light_green-neu.gif"); break; case 2: traffic = new GifImage(realPath + "/static/images/traffic_light_yellow-neu.gif"); break; case 3: traffic = new GifImage(realPath + "/static/images/traffic_light_red-neu.gif"); break; default:  
; traffic = new GifImage(realPath + "/static/images/traffic_light_grey-neu.gif"); break; } Image image = traffic.getImage(1); // 1 == frame image.setAlignment(Image.ALIGN_LEFT);
//document.add(image);
span> cell = new Cell(image); cell.set cell.add(msNamePhrase); cell.setBorderWidth(1); cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); cell.setHorizontalAlignment(Cell.ALIGN_CENTER); headTable.addCell(cell); } catch (BadElementException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { &n bsp; // TODO Auto-generated catch block // Gifs couldn't be found. e.printStackTrace(); }
try { cell = new Cell(customerPhrase); cell.setBorderWidth(1); &n
bsp; cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); cell.setHorizontalAlignment(Cell.ALIGN_CENTER); headTable.addCell(cell); } catch (BadElementException e) { // TODO Auto-generated catch block e.printStackTrace();n>
}
try { cell = new Cell(projectPhrase); cell.setBorderWidth(1); cell.setVerticalAlignment(Cell.ALIGN_MIDDLE); cell.setHorizontalAlignment(Cell.ALIGN_CENTER); head
Table.addCell(cell); } catch (BadElementException e) { // TODO Auto-generated catch block e.printStackTrace(); }
return headTable; }//end initHeader
and here's the code to convert the Table to a PdfPTable.
Table t = initHeader(); t.setConvert2pdfptable(true); PdfPTable p = t.createPdfPTable();
When I simply do this:
document.add(image);
the image is displayed in its original (small) size.
So, how can I achieve that the image is not upscaled?
Thank you, Dirk
-- GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist! NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl
-- Mit freundlichen Grüßen
Dirk Ulrich
Jansenstraße Berlin
fon:0++49-(0)30-40 999 087
mobil:++49-(0)174/948 87 39
GMX DSL-Flatrate 0,- Euro* - Überall, wo DSL verfügbar ist! NEU: Jetzt bis zu 16.000 kBit/s! http://www.gmx.net/de/go/dsl
|
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions