PDF in JAVA

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2006
Posts: 20
Reputation: michael.ngobeni is an unknown quantity at this point 
Solved Threads: 0
michael.ngobeni michael.ngobeni is offline Offline
Newbie Poster

PDF in JAVA

 
0
  #1
Jul 9th, 2007
Good day,

I have a PDF file that acts as my template. I know how to use the x, y cordinate to put an image into that PDF file. My problem is that my PDF file has about five pages and I want to put this image in the second and forth page.

How do I do that?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,196
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 485
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: PDF in JAVA

 
0
  #2
Jul 9th, 2007
iText library is one of the options
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: PDF in JAVA

 
0
  #3
Jul 10th, 2007
Since when is PDF read/write?
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,479
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 514
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: PDF in JAVA

 
0
  #4
Jul 10th, 2007
Originally Posted by jwenting View Post
Since when is PDF read/write?
Well, only sort of. There are several writer objects in iText that allow you to import existing PDF content and generate new output content. I think that what the OP is wanting to do would be possible in iText, but I can't say from direct experience there.

Here is a bit of tutorial on manipulating existing docs with iText:
http://itextdocs.lowagie.com/tutoria....html#inaction
Last edited by Ezzaral; Jul 10th, 2007 at 6:28 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,196
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 485
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: PDF in JAVA

 
0
  #5
Jul 10th, 2007
It realy depends on what he is trying to do. He can always insert image/new data into existing documnet and they can be writen on new layer over existing content or he can put it below like a watermark. So michael you need to be more specific with this question...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 20
Reputation: michael.ngobeni is an unknown quantity at this point 
Solved Threads: 0
michael.ngobeni michael.ngobeni is offline Offline
Newbie Poster

Re: PDF in JAVA

 
0
  #6
Jul 11th, 2007
I managed to get it.
I had a PDF file that had about 10 pages and I wanted to insert an image on every page.

This is what I did

import com.lowagie.text.Image;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;

.
. Start Class
.
.
.
private PdfReader reader=null;
private PdfStamper stamp=null;
private PdfContentByte over=null;
.
.Start function
.

reader = new PdfReader("MyPDFFile.pdf");
int NumberOfPages = reader.getNumberOfPages();
int startPageLoop = 0;

Image img;
img = Image.getInstance("C:\Images\Your_Mother.jpg");

while (startPageLoop < NumberOfPages) {
startPageLoop++;
over = stamp.getOverContent(startPageLoop);
img.setAbsolutePosition(x, y);
over.addImage(img);
}
.
.
.
.
.end function
.
Thanks for your help anyway
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC