QuadBounds Order for PdfAnnotation markup using itext or pdfbox

橙三吉。 提交于 2019-12-10 10:48:13

问题


  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


回答1:


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.




回答2:


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)



回答3:


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() };


来源:https://stackoverflow.com/questions/18781923/quadbounds-order-for-pdfannotation-markup-using-itext-or-pdfbox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!