0 1 2 3
* (x1,y1) *************** (x2,y2)
* * *
* * *
* 4 5 * * 6 7
* (x3,y3) *************** (x4,y4)
is this correct order for float array for PdfAnnotation or PDFAnnotation? i tried creating a pdf annotation but the annotations are concave not convex like the those generally created by using adobe reader or acrobat
What I found using iText was the following:
* 4 5 6 7
* (x3, y3) ***************** (x4, y4)
* * *
* * *
* * *
* 0 1 * * 2 3
* (x1, y1) ***************** (x2, y2)
Using this order made my highlights output with the same convex effect as the highlight annotation tool in Adobe Acrobat.
The Pdf specification states on the quadrilateral coordinates:
The coordinates for each quadrilateral are given in the order
x1 y1 x2 y2 x3 y3 x4 y4
specifying the four vertices of the quadrilateral in counterclockwise order. For orientation purposes, such as when applying an underline border style, the bottom of a quadrilateral is the line formed by (x1, y1) and (x2, y2).
(multiple subsections of section 12.5.6 in ISO 32000-1)
Thus:
* 6 7 4 5
* (x4,y4) *************** (x3,y3)
* * *
* * *
* 0 1 * * 2 3
* (x1,y1) *************** (x2,y2)
I had the same problem with iText 2.1.7 and it was driving me crazy. The order jrubins described did not work for me, it produced concave annotations. Eventually i found the right order, which is lr > ll > ur > ul .
/*
* PDF Specification Order - results in broken annotation
*
* 7,8 5, 6
* (x,y)___________(x,y)
* | |
* | |
* |___________|
* (x,y) (x,y)
* 1, 2 3, 4
*/
/*
* Concave order - results in working, but concave annotation; don't know why
*
* 5, 6 7, 8
* (x,y)___________(x,y)
* | |
* | |
* |___________|
* (x,y) (x,y)
* 1, 2 3, 4
*/
/*
* Convex order - this is the one working like expected:
*
* 7,8 5, 6
* (x,y)___________(x,y)
* | |
* | |
* |___________|
* (x,y) (x,y)
* 3, 4 1, 2
*/
float[] quad = { rect.getRight(), rect.getBottom(), rect.getLeft(),rect.getBottom(), rect.getRight(), rect.getTop(),
rect.getLeft(), rect.getTop() };