-1

I want to get image field from existing pdf and fill it with other image to create new pdf file using pdfbox library in java

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90

1 Answers1

0

If your trying to get image coordinates from a PDF you could try PDF Mantis which has a function to extract this information - See example below:

// Load your PDF
PdfMantis pdf = new PdfMantis("/home/example.pdf");

// Get the image index
List <ImageIndex> imageIndex = pdf.getImageIndex().buildIndex();

// Iterate over each entry in the index
for (ImageIndex image : imageIndex) {

    // And then we can get coordinates like so...
    image.getX();
    image.getY();
    image.getHeight();
    image.getWidth();
}

Disclaimer: I am the developer of PDF Mantis.

  • In the question text it is clarified that this is about an "image field" (i.e. a push button field with some Javascript). Does your code really extract data on such fields? – mkl Nov 30 '21 at 23:39
  • Ah. The title and the question text are somewhat conflicting, as the question text makes no reference to image coordinates, despite the title explicitly asking for them. So in answer to your question, no, it doesn't cover "image fields" but the answer doesn't claim to either. – Ben-Grayson-Norland Dec 01 '21 at 00:44