Hello i need to retrieve pdf files from database for further work with Pdfbox. How to merge multiple pdf files located in database with Pdfbox? I want to download them using Hibernate but Pdfbox need source location (String/direcory) and destination directory (also String/direcory). Another problem is that Spring is uploading and downloading files as Multipart files and Pdfbox needs Inputstream or File (bytes?). Do you have any idea how to merge multiple pdfs (saved in database) into 1 pdf using Pdfbox ? This merged pdf will be also saved into database. Thanks for help.
Asked
Active
Viewed 209 times
-1
-
You need to write questions that are more focused on specific problem [How to ask | https://stackoverflow.com/help/how-to-ask] – gfelisberto Jan 17 '21 at 21:42
-
`Multipart` has a `getInputStream()` method https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/multipart/MultipartFile.html – Tilman Hausherr Jan 18 '21 at 05:00
1 Answers
0
I think a good approach would be to separate the problems and solve them one by one.
Do you have any idea how to merge multiple pdfs (saved in database) into 1 pdf using Pdfbox? I dont know Pdfbox in detail but if it asks for a file you could use a temporary direcotry and store the file there. from there you could read the bytes and save them to your database. see also: How to create a temporary directory/folder in Java?
Another problem is that Spring is uploading and downloading files as Multipart files and Pdfbox needs Inputstream or File (bytes?) I dont understand the question exactly. If PdfBox needs an Inputstram you could take a look at the ByteArrayInputStream class.

benebo22
- 241
- 2
- 5