Im migrating my PDFBox 1.8.x to 2.0.12 and have to fight some changes.
The last one that I can't figure out is occuring in the code seen below.
public static byte[] mergeDocuments(byte[] document1, byte[] document2) {
try (PDDocument pdDocument1 = load(document1); PDDocument pdDocument2 = load(document2)) {
final List<PDPage> pages1 = getPages(pdDocument1);
final List<PDPage> pages2 = getPages(pdDocument2);
pages1.addAll(pages2);
return createDocument(pages1);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static List getPages(PDDocument pdDocumentTarget) {
return pdDocumentTarget.getDocumentCatalog().getAllPages();
}
Error occurs on the last line, I have to change the old ".getAllPages()" to ".getPages", but then I get PDPageTree as return and not List.
Code is written some years ago and not by me. I have tried some things like casting or changing the types, but it allways results in errors in different places.
Thanks in advance for any help