Hello,
I have been working with pdfbox for quite some time for my thesis topic and
now I am facing an issue when I try to load multiple pdf files.
So I have multiple files constructed and I return them in a list as
multipart files, I loop through and in each iteration I load the document
by using load function like this PDDocument.load(multipartFile.getBytes()).
This is the code that is not working as intended inside a loop.
try (PDDocument document = PDDocument.load(multipartFile.getBytes())) {
System.out.println(multipartFile.getBytes().length);
System.out.println(multipartFile.getOriginalFilename());
System.out.println(document.hashCode());
// -------------------------------------------------------
System.out.println(document.getDocumentInformation().getTitle());
System.out.println(document.getNumberOfPages());
} catch (IOException e) {
throw new RuntimeException(e);
}
Byte length, multipartFile name and document hash code is different in each
iteration but when i try to access document information or document number
of pages is always the same.
I would appreciate it if you could give me some direction on how to solve
this issue. I spent a couple days debugging.
Best regards,
Pellumb Baboci