This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Combine multiple pdf files into one page pdf

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This will be run via javascript on a web app.

I have a bunch of PDFs that are 8 1/2 x 11, but only has content in the top 2 inches. A standard merge of 10 of these PDFs would create a 10 page document.

But I could actually fit 5 of those blocks on a single page, resulting in a 2 page document after merging those same 10 files.

Does that make sense? How can I do that. I'm currently using PDFBlock, but I'm open to using other open source libraries.
 
Saloon Keeper
Posts: 5707
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what PDFBlock is -a quick web search finds nothing- but Apache PDFBox can do this: https://pdfbox.apache.org/2.0/commandline.html#pdfmerger
 
Keith Price
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dang it! Yeah, I must have been pretty tired when I wrote that. I did mean PDFBox (sort of a block, right?)

I've looked at pdfmerger, but got the impression that it inserted a page break after every merged document. No?

In my case, my PDFs are full page, but 4/5ths of the page is blank. I only want to merge in the part that has content.

Can pdfmerger do that?
 
Tim Moores
Saloon Keeper
Posts: 5707
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said, PDFBox can do this. Since you are already using it, why are you contemplating some other library?

Copying just parts of a page is quite tricky, no matter which library you use. Unless you have quite some time to spend, or money to license something from Adobe, I advise to leave out that part.
 
Keith Price
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only because I didn't realize it can do it. I can't find any examples or of people discussing doing that, so I posted here for ideas.  All the examples I found show each merged file coming in on it's own page. I'll go try it and see what happens, but if you have any hints or links that clover that, I'd appreciate it.

Thanks for your help.
 
Tim Moores
Saloon Keeper
Posts: 5707
144
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with merging PDFs in this way is that PDF content -once created- is tied to particular positions on the screen. So if you have two PDFs with half a page of content each, merging them will (at best) result in a page with both content sort of overlaid on top of each other on the top half of the output PDF.

No free tool I'm aware of can address this on its own (which is why I pointed to Adobe's tools, which may have an API that helps with this, but which will certainly cost you quite a bit).
 
Keith Price
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Moores wrote:
Copying just parts of a page is quite tricky, no matter which library you use. Unless you have quite some time to spend, or money to license something from Adobe, I advise to leave out that part.



So, I've modified my source files to be smaller paper size. This will allow me to merge the entire file without needing to take a portion of it. But, now the second file is merely overwriting (or overlaying) the first one. Any suggestions?

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!