简体   繁体   中英

Add PDFs together in Java

I am using an api which allows me to generate reports in PDF format. From the api I get the PDF in a byte[] . I send the reports to users via e-mail. Sometimes users will get one report, but in many cases they'll get many reports.

I'm wondering whether it's possible to take the bytes for more than one pdf and combine them in some way with another (or many) report(s) so I only send the user one pdf rather than 3 or 4. Thanks for the help!

No, concatenating the bytestream will not work (read the standard ;-). You need to use something like Apache PDFBox to create a new PDF.

I highly recommend IText for generating and manipulating pdfs in Java. But even if you want to use your orginal package to generate the pdf, you can still use IText to merge all your pdfs together into 1 big pdf, as explained here: iText Merge PDF with cropbox

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM