Search code examples
pdfbox

How to use pdfbox to replace pictures in pdf files


I found a code:

        PDResources res = page.findResources();
    Map<String, PDXObjectImage> imgs = res.getImages();
    res.setXObjects(newImgs);
    page.setResources(res);
    PDDocument newDcoument = new PDDocument();
    newDcoument.addPage(page);
    newDcoument.save(pdfname);

But the code is invalid,Is there any other way


Solution

  • I chose RandomAccessFile to find the signature and then replace the keyword.