so im working on a pdf accessiblity and doesnt have much knowledge about java, so ive ask chatgpt to make a code for pdfbox the script should delete all “Span” tags but retain its child (leaf node), but the code only works properly if Span’s child tag is not a leaf node, if it is a leaf node the child tag becomes blank, ill appreciate any insights regarding this, thaaaanks
private static void processElement(PDStructureElement element, List<Object> parentKids) {
List<Object> kids = element.getKids();
List<Object> newKids = new ArrayList<>();
if ("Span".equals(element.getStructureType())) {
parentKids.addAll(kids);
} else {
for (Object kid : kids) {
if (kid instanceof PDStructureElement) {
processElement((PDStructureElement) kid, newKids);
} else {
newKids.add(kid);
}
}
element.setKids(newKids);
parentKids.add(element);
tried reconstructing the pdf structure and the java code
New contributor
Darryl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.