Try to recreate the problem with some complete and working code.
Also, the hashcode would be different even if the file is the same. You
should calculate the hash of multipartFile.getBytes()
System.out.println(Hex.getString(MessageDigest.getInstance("MD5").digest(multipartFile.getBytes())));
Tilman
On 30.03.2023 02:13, pellumb baboci wrote:
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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]