Recommand · October 22, 2021 0

Error while merging PDF document using PDFBox

Currently i’m getting java.io.IOException: Expected string, found COSDictionary{COSName{ID}:COSString{node00001218};COSName{K}:…., i’m using below code to merge pdfs and version of PDFBox is 2.0.24.

PDFMergerUtility merger = new PDFMergerUtility();
Path mergedTempFile = Files.createTempFile("merge_", ".pdf");
merger.setDestinationFileName(mergedTempFile.toString());
merger.addSource(new File("D://1.pdf"));
merger.addSource(new File("D://2.pdf"));
merger.mergeDocuments(null);

i’ve also executed the same code with latest version of PDFBox 3.0.0-alpha2 but error was not resolved.

How can i resolve this ?