You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Zhu Yi <zh...@student.ethz.ch> on 2014/07/10 16:50:09 UTC

Problems of Highlight with PDFbox

Hi Im a newer to Pdfbox and I want to highlight certain character of PDF files. Right now I can get the coordinates of the character and I want to highlight it.

I saw on this link: highlight text using pdfbox when it's location in the pdf is known<http://stackoverflow.com/questions/18463543/highlight-text-using-pdfbox-when-its-location-in-the-pdf-is-known>

that shows the steps to highlight.

My question lies on these 2 steps: markup.setRectangle(); markup.setQuads();

I've tried to understand Quadpoints and PDRectangles but failed.

Actually if I wrote code like this:

    PDRectangle position = new PDRectangle(50,50);
    markup.setRectangle(position);
    float []p=new float[8];
    p[0]=100;p[1]=100;p[2]=200;p[3]=100;p[4]=100;p[5]=500;p[6]=200;p[7]=500;
    markup.setQuadPoints(p);


I would get nothing, but if I set LowerLeftX,LowerLeftY,UpperRightX,UpperRightY for PDRectanlge I could get the highlited text,but the coordinates are not what I expected.

Could any one explain to me the difference between these two classes? Since I already have 4 points in Quadpoints, why do I still have to add the position of the Rectangle?What realations do these 2 classes have?


Thanks!