944,117 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1427
  • Java RSS
Jul 9th, 2007
0

PDF in JAVA

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
michael.ngobeni is offline Offline
20 posts
since Dec 2006
Jul 9th, 2007
0

Re: PDF in JAVA

iText library is one of the options
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,659 posts
since Dec 2004
Jul 10th, 2007
0

Re: PDF in JAVA

Since when is PDF read/write?
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jul 10th, 2007
0

Re: PDF in JAVA

Click to Expand / Collapse  Quote originally posted by jwenting ...
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.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Jul 10th, 2007
0

Re: PDF in JAVA

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...
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 874
Code tags enforcer
peter_budo is offline Offline
6,659 posts
since Dec 2004
Jul 11th, 2007
0

Re: PDF in JAVA

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
michael.ngobeni is offline Offline
20 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: What is MVC pattern
Next Thread in Java Forum Timeline: Need help with javax.mail api





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC