3

How can I get the color at a specific coordinate in a pdf file.? Also, I do not know the coordinates. I have only a pdf file. I need to find out a coordinate and its color. I work in java and "com.lowagie.text.pdf" package. Please help me.

user606423
  • 27
  • 4
skmaran.nr.iras
  • 8,152
  • 28
  • 81
  • 116
  • 1
    how do you want to get the color of a coordinate if u don't even know the coordinate? With which criteria do u wanna find out the coordinate? – Sören Feb 07 '11 at 12:42
  • @Soren : you are right. But whatever may be the coordinate I want to get the color. for testing a feasible coordinate can be selected. – skmaran.nr.iras Feb 07 '11 at 12:51
  • 1
    Do u know the page u want the coordinate and its color? – Timmo Feb 07 '11 at 13:39

2 Answers2

2

If you know the page then take the image of the page:

PdfImportedPage page = writer.getImportedPage(reader, pageNum); // get the page of the PDF Image img = Image.getInstance(page); // wrap it in an image object

From there on convert the Image to a byte array and get your color at your coordinate.

Timmo
  • 3,142
  • 4
  • 26
  • 43
1

I got what I was looking for.

The code is here

Export PDF pages to a series of images in Java

Community
  • 1
  • 1
skmaran.nr.iras
  • 8,152
  • 28
  • 81
  • 116