Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Concatinating two pdf files in java

 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I write java program to concatenate or merge two pdf files into one?
Can I do this using just java or need to use any third party software? If it is not possible, what is the free softwares available for this purpose?
Thanks in advance.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a nice set of libraries called iText that you can use to read and write PDFs. There is also a nice package called pdftk that you can use to manipulate PDFs.
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Keith. I will go through those site and I know about them earlier.
I dont want to read or write pdfs.. I have all the pdfs and just I have to merge them into one.. Is it possible without them or will there be some functions in those api's to do this job?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34195
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rizwan Mohammad:
Is it possible without them or will there be some functions in those api's to do this job?

No. A PDF contains hash like data about the whole file along with headers. You can't just concatenate them without reading them in first.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rizwan Mohammad:
Thanks Keith. I will go through those site and I know about them earlier.
I dont want to read or write pdfs.. I have all the pdfs and just I have to merge them into one.. Is it possible without them or will there be some functions in those api's to do this job?


There are ways in both iText and pdftk. pdftk is probably easier to use for it since it is a command line program and you simply feed in the names of the .pdf files that you want to merge.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iText also comes with a ready-to-use example program that shows how to concatenate files.
 
Rizwan Mohammad
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf & Keith, Thanks for your solutions. These helped me a lot.
 
Megan James
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could any one know how read the pdf with font style, family and size for each and every word or line?.

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay,
your question has nothing to do with what was discussed above. Please don't post unrelated questions into existing topics; that's called "hijacking" and is frowned upon. Please start a new thread instead.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic