How do I fix the Tagged Annotations fail/error for accessibility for links using pdfbox java?

依然范特西╮ 提交于 2020-05-13 14:01:10

问题


Found the solution by using adobe - https://answers.acrobatusers.com/How-I-fix-Tagged-Annotations-fail-error-accessibility-links-q228128.aspx

How can I add Link-OBJR (object reference to link annotation) using pdfbox.

       `PDAnnotationLink txtLink = new PDAnnotationLink();
        PDRectangle position = new PDRectangle();
        position.setLowerLeftX(PDFUtils.lw_lft_x);
        position.setLowerLeftY(PDFUtils.lw_lft_y);
        position.setUpperRightX(PDFUtils.tp_rgt_x);
        position.setUpperRightY(PDFUtils.tp_rgt_y);
        txtLink.setRectangle(position);
        txtLink.setHidden(true); 
        txtLink.getCOSObject().setInt(COSName.STRUCT_PARENT,1); 
        PDActionURI action = new PDActionURI();
        action.setURI(PDFUtils.link);
        txtLink.setAction(action);
        page.getAnnotations().add(txtLink);
        PDObjectReference pd= new PDObjectReference();
        pd.setReferencedObject(txtLink);
        structureElement.appendKid(pd);
        currentSection.appendKid(structureElement);
        structureElement formBuilder.addContentToParent(COSName.P, null, page, structureElement, PDFUtils.mcid);`

Tagged using above code-

Tagged using above code

Tagged document reference- https://drive.google.com/file/d/1n_T361G6LTNLycQbw-3gP2nmBV-oTJdR/view?usp=sharing

Looking for below structure

Looking for like this structure

来源:https://stackoverflow.com/questions/59172513/how-do-i-fix-the-tagged-annotations-fail-error-for-accessibility-for-links-using

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