Screen reader /Tag order issue - Image between text

Hi Team,

We are converting Word document to PDF using Aspose Words java -

Word document has inline Image with text.

Converted PDF has incorrect tag order and also screen reader order is incorrect.

Expected Order - Text before Image - Image - Text after Image
Actual Order - Text before Image -Text before Image - Image

Attached the sample WORD and PDF documents.

Could you help to verify and let me know if you need further information. Thank you.
image with in text.docx (10.7 KB)
image with in text.pdf (17.5 KB)

@cvsformulary I have checked conversion of your document to PDF using MS Word and tags order is the same. ms.pdf (33.1 KB)
Aspose.Words in this case behaves the same as MS Word.

Could you please suggest if there is anyway we can achieve the reading order. Without using images or any other way .

Our goal is to add a alternate/hidden text that screen reader can read before a text. Adding image is not our requirement.

Expected Order - Before Text - Alternate text/hidden text for screen reader- After Text

Thank you.

@cvsformulary You can try to put some pseudo-hidden content, which is invisible by ayes, but will be read by screen reader. For example, you can put text with negative character spacing so characters overlap and make this text white. For example see the following code:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.write("This is content before");

builder.getFont().setColor(Color.WHITE);
builder.getFont().setSpacing(-10);
builder.write("This is content between");

builder.getFont().clearFormatting();
builder.write("This is content afters");

PdfSaveOptions opt = new PdfSaveOptions();
opt.setCompliance(PdfCompliance.PDF_UA_1);
doc.save("C:\\Temp\\out.pdf", opt);

out.pdf (21.6 KB)

Thank you for the solution. This is working as expected.

1 Like