pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Haggai <stephenhag...@gmail.com>
Subject Replacing an image in a PDF file using PDFBox
Date Fri, 08 May 2015 00:06:50 GMT

I am trying to replace an image in a PDF file using PDFBox and I am unable
to find any examples. The only example that I found on
uses COSStream's replaceWithStream(COSStream stream) that has been
deprecated. Are there any alternatives to this method or is there another
process that I can use.

private static void changeImage(COSObject obj, PDDocument doc) {

    PDXObjectImage imageInPdf =
        (PDXObjectImage) PDXObject.createXObject(
            (COSStream) obj.getObject());

    File inputFile = new File("C:\\temp\\SIGNATURE.jpg");
    PDXObjectImage newImage = new PDJpeg(
        doc, new FileInputStream(inputFile));


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message