Isn't it rather that you should create the PDF with all the text first and
then put the background image into it using getUnderContent() ???

john renfrew 


-----Original Message-----
From: Jeff Sadowski [mailto:jeff.sadow...@gmail.com] 
Sent: 04 January 2012 21:42
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] A simple image background with text overlayed?

I can't seem to find an example that fits my simple situation. All the
examples I have found for what I want use a pdfreader object and a
pdfstamper object
then they use .getUnderContent(); method and .getOverContent() method.
pdfreader from what I gather needs an existing pdf do I need to
convert my jpgs to pdfs first? Or is there a simple way to overlay
text.
here is the code I have so far.

<------ code snipit
 try {
  Document doc=new Document(PageSize.LETTER,0,0,0,0);
  PdfWriter writer = PdfWriter.getInstance(doc,new
FileOutputStream("background.pdf"));
  Image img = Image.getInstance("C:/background.jpg");
  img.scaleToFit(PageSize.LETTER.getHeight()*1.3f,
PageSize.LETTER.getWidth()*1.3f);
  img.setAbsolutePosition(0,0);
  doc.open();
  doc.add(img);
  doc.close();
 } catch (Exception e) {
  e.printStackTrace();
 }
<----- end code snipit

this creates a background pdf that I could use pdfreader and
pdfstamper on but I'd like to do it without creating an intermediate
file if possible.
Is there a simple way to overlay text on a background image?

----------------------------------------------------------------------------
--
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
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



------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
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

Reply via email to