Accessibility Check on Merged PDF fails with 'Other elments alternate text - Failed'

Hello ,
I am trying to merge two pdf files from trial version of Aspose 23.3 (aspose-pdf-23.3.jar)
The independent pdf files when checked for Accessibility comes fine with no errors.

After the merge however, we notice the page 2 has accessibility issue and it fails with the ‘Other elements alternate text - Failed’ error.

The code snippet is

// The path to the documents directory.
private static String _dataDir = "C:\\WD\\Activities\\merge-pdfs\\inputs\\";

private static String outputDir = "./";

public static void Merge() throws Exception {

	long time = new Date().getTime();

	// Open first document
	Document pdfDocument1 = new Document(_dataDir + "page_1.pdf");
	// Open second document
	Document pdfDocument2 = new Document(_dataDir + "page_2.pdf");
	// Add pages of second document to the first
	pdfDocument1.getPages().add(pdfDocument2.getPages());

	String outputName = outputDir + "merged_out_" + time + ".pdf";
	System.out.println(outputName);

	// Save concatenated output file
	pdfDocument1.save(outputName);
}

I m not sure how can i upload the sample files for reference. Therefore, i have shared the file from github at https://github.com/manoharanhariharan/Share/blob/main/aspose-pdf-2.zip

@hariharanm,

I found some issues, but I want to review them with you to be sure we are on the same page.

When I validate every document by itself, they have 2 issues, both of them have the same issues:

Document 2:

But the merge result has other accessibilities issues that were not present on the documents by themselves:

This is the report I get from merging the PDFs with the latest version of Aspose Pdf API.

Was this the problem you were talking about?

The files:

MergeDocuments_input_1.pdf (104.3 KB)
MergeDocuments_input_2.pdf (115.9 KB)

MergeDocuments_output.pdf (97.6 KB)

Hi Carlos,

Thanks for looking at it.
The independent files having those two issues ‘Logical Reading Order …’ and ‘Color contrast …’ are fine. What we are facing comes under Alternate Text > Other elements alternate text - Failed’
I have attached the snapshot as reference for you here.
image.png (35.6 KB)

Thanks
Hari

@hariharanm,

This seems to be a bug. I will collect all this data and files and submit a ticket to the dev team now.

Thank you very much Carlos :slight_smile:

@hariharanm
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-54482

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

@hariharanm

We have completed the investigation of the ticket. If you want to keep PDF_UA (StructTreeRoot). Better to use “PdfFileEditor” with “CopyLogicalStructure”.

var doc1 = new Document($"{PartialPath}MergeDocuments_input_1.pdf");
var doc2 = new Document($"{PartialPath}MergeDocuments_input_2.pdf");
var pdfFileEditor = new PdfFileEditor()
{
    CopyLogicalStructure = true,
    KeepActions = true,
    CopyOutlines = true
};
pdfFileEditor.Concatenate(new Document[] { doc1 }, doc2);
doc2.Save($"{PartialPath}MergeDocuments_output_fe.pdf");

The result of the code snippet keeps “StructTreeRoot” information and looks better.
MergeDocuments_output_fe.pdf (171.7 KB)

Hi Asad, thanks for replying.
I tried your approach and found that it works fine when we try as below

pdfFileEditor.Concatenate(new Document[] { doc1 }, doc2);

but, if i try below, it fails with same error.

pdfFileEditor.Concatenate(new Document[] { **doc2** }, **doc1**);

I m uploading snapshot of the source implementation for your reference.
image.png (23.3 KB)

Also, i am attaching the output that t
merged_out_1706082834461.pdf (276.8 KB)

the file generated
image.png (31.4 KB)

@hariharanm

It looks like you are using an older version of the Java API. Please use the latest version i.e. 24.1 with a valid license and share with us if you still notice this issue. We will further proceed to assist you accordingly.

Hi Asad,
As suggested by you., i used the latest 24.1 and i m still seeing the issue in the generated document.
Please find attached pdf for your reference.
image.png (31.0 KB)

Thanks

@hariharanm

Thanks for the confirmation. Would you kindly share the sample input document as well for our reference? We will log a dedicated ticket in our issue tracking system for this case and share the ID with you.

Its the same document that I had attached previously. However, i am attaching them again for your quick reference here.
MergeDocuments_input_1.pdf (104.3 KB)

MergeDocuments_input_2.pdf (115.9 KB)

Thanks
Hari

@hariharanm

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-43523

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.