Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 6th, 2010, 09:26 PM
doush. doush. is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 119 doush. User rank is Private First Class (20 - 50 Reputation Level)doush. User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 6 h 2 m 7 sec
Reputation Power: 8
Exclamation IText PDF template help

Hey all, was just wondering if anyone would be able to help me out.

I'm currently creating a pdf document using the iText classes. All has gone fine but now I'm trying to export using a template document.

All I want the template document to be used for is a background image. So every page that is in the new document to contain the background. I have sort of got this working but I'm having a couple problems.

1. The template appears over the added content/text? I add the template first and then the content so not sure what happening there.

2. It only appears on the first page. I'm not sure how to make it appear on all the pages?

Heres what I'm doing
Code:

FileOutputStream outputStream = new FileOutputStream("file.pdf");

Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, outputStream);
document.open();

PdfReader reader = new PdfReader("template.pdf");

PdfImportedPage page = writer.getImportedPage(reader, 1);

PdfContentByte cb = writer.getDirectContent();
cb.addTemplate(page, 0, 0);

document.add(new Paragraph("Test Text");

documnet.close();


Any idea?

Reply With Quote
  #2  
Old November 7th, 2010, 09:14 PM
doush. doush. is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 119 doush. User rank is Private First Class (20 - 50 Reputation Level)doush. User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 6 h 2 m 7 sec
Reputation Power: 8
Does anyone know how to use iText to add an image to the background off all pages within a pdf. Can't really find a solution anywhere.

Reply With Quote
  #3  
Old November 7th, 2010, 09:36 PM
doush. doush. is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 119 doush. User rank is Private First Class (20 - 50 Reputation Level)doush. User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 6 h 2 m 7 sec
Reputation Power: 8
Quote:
Originally Posted by doush.
Does anyone know how to use iText to add an image to the background off all pages within a pdf. Can't really find a solution anywhere.


All good people, I've got it working. For those wondering, I justed used a water mark. Just add it before you call document.open() and it will add to all pages

headache gone now

Reply With Quote
  #4  
Old November 8th, 2012, 12:35 PM
mastershedder mastershedder is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 mastershedder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 37 sec
Reputation Power: 0
Getting the content in the background

To get the content to appear below the text (as a background image) use writer.getDirectContentUnder()

See this page for more information ( http :// stderr . org/doc/libitext-java-doc/www/tutorial/ch10.html

I don't know how to repeat on every page yet.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > IText PDF template help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap