Here it goes: some meaningless code omitted.

PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream
());
document.open();

Paragraph title = new Paragraph ("Some Text", new Font(Font.TIMES_ROMAN, 40,
Font.BOLD));
tittel.setAlignment (Element.ALIGN_CENTER);
document.add(title);

String infotextString = "Some text Some text Some text Some text";
Paragraph infotext = new Paragraph(infotextString, new Font(Font.TIMES_ROMAN,
18, Font.NORMAL, new Color (255, 0, 0)));
document.add(infotext);

float[] widths1 = { 0.4f, 0.4f, 0.7f };
PdfPTable table = new PdfPTable(widths1);
table.setSpacingBefore(30f);
table.setSpacingAfter(15f);
table.setWidthPercentage(70);
table.getDefaultCell().setBorderWidth(0.5f);
table.getDefaultCell().setBorderColor(Color.red);
table.getDefaultCell().setPaddingBottom(2);
table.getDefaultCell().setPaddingTop(2);
table.getDefaultCell().setUseDescender(true);
Paragraph brann = new Paragraph("text: 110", new Font (Font.TIMES_ROMAN, 18,
Font.NORMAL));
Paragraph politi = new Paragraph("text: 112", new Font (Font.TIMES_ROMAN,
18, Font.NORMAL));
Paragraph ambulanse = new Paragraph("text: 113", new Font (Font.TIMES_ROMAN,
18, Font.NORMAL));
table.addCell(brann);
table.addCell(politi);
table.addCell(ambulanse);
document.add(table);

//Main image
Paragraph imagetitle = new Paragraph("Image text", new Font(Font.TIMES_ROMAN,
14, Font.BOLD));
document.add(imagetitle);
String URL = (String)request.getSession().getAttribute("getMapURL");
Image image = Image.getInstance(new URL(URL));
image.scaleToFit(PageSize.A4.width(), PageSize.A4.height());
image.setAlignment(Image.MIDDLE | Image.TEXTWRAP);
image.setAbsolutePosition(0, 335);
document.add(image);

//transparent Image overlay
String imageURL = request.getRequestURL().substring(0, request.getRequestURL
().lastIndexOf("/"));
Image image2 = Image.getInstance(imageURL+"/img/overlay.png");
image2.scaleToFit(PageSize.A4.width(), PageSize.A4.height());
image2.setAlignment(Image.MIDDLE | Image.TEXTWRAP);
image2.setAbsolutePosition(0, 335);
document.add(image2);

String sname =
((String)request.getSession().getAttribute("stedsnavn")).trim();
float userdefinedWidth = new Chunk(sname, new Font(Font.HELVETICA, 22,
Font.NORMAL)).getWidthPoint();
float fixedWidth = new Chunk("Textname:", new Font(Font.HELVETICA, 22,
Font.NORMAL)).getWidthPoint();
float padding = 20;
float[] widths2 = { fixedWidth + padding, userdefinedWidth + padding};
PdfPTable table2 = new PdfPTable(widths2);
table2.getDefaultCell().setBorderWidth(0f);
table2.setTotalWidth(widths2);
table2.setLockedWidth(true);
table2.setSpacingBefore(40f);
table2.setSpacingAfter(10f);
Paragraph stitle = new Paragraph("Stedsnavn:", new Font(Font.HELVETICA, 22,
Font.BOLD));
Paragraph snameP = new Paragraph(sname, new Font(Font.HELVETICA, 22,
Font.NORMAL));
table2.addCell(stitle);
table2.addCell(snameP);
document.add(table2);

2007/3/23, Paulo Soares <[EMAIL PROTECTED]>:

Prepare a small but complete standalone example that includes the image,
don't bother about the gif for now. Attach the code, the image and the
gif to the message. I'll tell you how to put the gif in the right place.

Paulo

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Sverre Moe
> Sent: Friday, March 23, 2007 10:10 AM
> To: [email protected]
> Subject: Re: [iText-questions] Overlay a transparent gif on
> another image
>
> Whatever I do I can't seem to get it right. I'm now using
> ColumnText to add both the text, tables and images.
> But I still get the previous problem when adding the images
> as absolute positions.
>
> PdfContentByte cb = writer.getDirectContent();
> ColumnText ct = new ColumnText(cb);
> ct.setSimpleColumn(0f, 0f, PageSize.A4.width() - 5,
> PageSize.A4.height() - 5, 18, Element.ALIGN_JUSTIFIED);
>
> First I add some text, a table and some text to the
> ct.addElement(). Then I add two images at the same absolute
> position 330 with cb.addImage()
> For last I add two tables with ct.addElement(), but these two
> are still aligned inside the image. How do I get the
> ColumnText to insert them after the image?
>
> I have found a temporary solution to this problem, but it is
> a ugly hack, 14 document.add(Chunk.NEWLINE) after adding the
> images. I would like to find a better solution
>
>
>


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão
desta mensagem não significa a perca de confidencialidade. Se esta mensagem
for recebida por engano, por favor envie-a de volta para o remetente e
apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o
destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may
contain confidential or legally protected information. The incorrect
transmission of this message does not mean the loss of its confidentiality.
If this message is received by mistake, please send it back to the sender
and delete it from your system immediately. It is forbidden to any person
who is not the intended receiver to use, distribute or copy any part of this
message.



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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/


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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/

Reply via email to