Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inserting a PDF document into a new PDF Page

 
Fred Khadour
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a project to insert PDF document in the middle of a PDF page built in Java (using iText Library). I am able to do that but my problem is that everytime it put the PDF document at the first page, at the top. I can not insert it where ever I want. I appreciate any help.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The PDFBox library can chop a PDF into individual PDFs containing one page each. It also can assemble a new PDF from single-page PDFs. Those two functionalities combined should let you achieve what you're asking. For high-level manipulations like this I find PDFBox easier to use than iText.
 
Fred Khadour
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer, Thank you for your help. In fact, I did what you said by using PDFBox library. I read PDF into PDDocument then into PDF pages. Each page is converted to BufferedImage then into Image so I can set the image inside PdfCell of iText (I have to build my PDF document with iText because I have other stuff to add to the page.) Anyway, it looks working fine. I am able to insert PDF images anywhere inside my new PDF document. However, it add extra empty page after each PDF image!!! Any clue how to fix that, thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic