Ich verwende PDFBox 3.0.2, um ein zugängliches PDF mit strukturierten Elementen zu generieren, aber ich versage den PAC-Test (PDF-Barrierefreiheitsprüfer), da ich einen PdannotationLink nicht richtig assoziieren kann.// Step 1: Create structure element
PDStructureElement element = new PDStructureElement(StandardStructureTypes.LINK, parentElement);
// Step 2: Create the accessible link annotation
PDAnnotationLink link = new PDAnnotationLink();
link.setPage(page);
PDRectangle linkRect = new PDRectangle(100, 100, 120, 15);
link.setRectangle(linkRect );
link.setContents(layoutInfo.text());
link.getCOSObject().setBoolean("IsMap", false);
PDObjectReference objRef = new PDObjectReference();
objRef.setReferencedObject(link);
element.appendKid(objRef);
link.setStructParent(structParentCounter);
page.getAnnotations().add(link);
PDActionGoTo action = new PDActionGoTo();
PDPageXYZDestination destination = new PDPageXYZDestination();
destination.setPage(page);
destination.setTop((int) 83);
action.setDestination(destination);
link.setAction(action);
page.getAnnotations().add(link);
// Step 3: Associate the marked content reference with the structure element
PDMarkedContentReference mcr = new PDMarkedContentReference();
mcr.setMCID(mcidCounter);
element.appendKid(mcr);
// Step 4: Define marked content properties
COSDictionary markedContentDictionary = new COSDictionary();
markedContentDictionary.setInt(COSName.MCID, mcidCounter);
markedContentDictionary.setString(COSName.CONTENTS, "*");
try {
PDPageContentStream contentStream = getCurrentLayoutState().contentStream();
contentStream.setLeading(LINIE_SPACING);
// Step 5: Begin marked content
contentStream.beginMarkedContent(COSName.getPDFName("link"), PDPropertyList.create(markedContentDictionary ));
contentStream.beginText();
contentStream.newLineAtOffset(100, 100);
contentStream.showText("*");
contentStream.endText();
contentStream.endMarkedContent();
// Step 6: Move to next MCID
mcidCounter++;
structureElementArray.add(element);
} catch (IOException e) {
e.printStackTrace();
}
< /code>
Obwohl ich den Inhalt strukturiert habe, erkennt PAC den PdannotationLink immer noch nicht als Teil der Struktur. Die Annotation ist im PDF sichtbar, erscheint jedoch nicht als Teil der Linkstruktur in Barrierefreiheitstools. Version: 3.0.2
[*] Ziel: PDF/UA -Konformität
[*] Problem: pdannotationLink nicht mit pdstructureElement
Was ich ausprobiert habe. richtig.
Wie ordnete ich PdannotationLink ordnungsgemäß mit pdstructureElement für PDF/UA -Konformität? ⇐ Java
-
- Similar Topics
- Replies
- Views
- Last post