HTML to PDF and keep accessibility in C#

I am converting an HTML document to a PDF document and I need to keep the accessibility tags for the generated PDF file. The input HTML document has valid accessibility that I confirm through file upload at Nu Html Checker

After the PDF document has been generated the document no longer has its accessibility features.
I have used the sample code from Aspose.

This is the exact code I have been using:
HtmlLoadOptions options = new HtmlLoadOptions();
var inputFilePass = Path.GetFullPath(@“…....\TestData\input_Pass.html”);
var output = Path.GetFullPath(@“…....\Output\output.PDF”);
Document pdfDocument = new Document(inputFilePass, options);
pdfDocument.Save(output);

I would really appreciate if anyone knows if it is possible to keep the accessibility features of the document when the document is converted from HTML to PDF.

@marot,

Can you attach the HTML sample in a zip file so I can check and pass it to the dev team if needed?

@carlos.molina
input_Pass.zip (561 Bytes)

@marot,

After research more the Accesbility features, they are all related to the creation of a PDF, but not loading it. Here is the documentation of how to create a tagged Pdf if that may help you.

@carlos.molina
Thank you for your reply. I just want to make sure I understand you fully. The provided code sample from Aspose on how to convert an HTML document to a PDF document does not support accessibility. But I would need to create the PDF document as described in the “Create Tagged PDF”, correct?

@marot,

Sorry if I was not clear. So far when loading an Html document to convert to a PDF document, the content is not created as tagged automatically.

When creating a document from scratch you can tag the content of the document by following the documentation procedures.

In summary, the code sample in the documentation are not to convert an HTML to a PDF tagged, but to create a PDF from scratch with tagged content.

So at the moment Aspose.Pdf does not support accesibility(tagged content) when loading a document from an Html source.

But when creating a PDF manually it does(if you create it following the documention).

1 Like

Hi Carlos,
Is this issue being addressed? We may need to switch to another vendor if the converted PDF files are non-compliant with WCAG 2.0 AA.

@boris.dongarov.tr

Do you want to convert the HTML to PDF with all accessibility features like tagging, alternative text, reading order and artifacts?

I’m not an accessibility specialist, but I can quote the requirements. I hope it helps.

What is an accessible PDF?

PDF documents are required by the Digital Accessibility Policy to meet or exceed the Web Content Accessibility Guidelines (WCAG) 2.0 at level AA. In addition to sufficient color contrast, content structure, and similar WCAG Success Criteria, accessible PDFs make use of the features specified in the Universal Accessibility (PDF/UA) standard to “tag” documents, exposing their semantic structure to assistive technologies. This is very similar in concept to using semantic HTML elements and ARIA roles and attributes to make web pages accessible.

@boris.dongarov.tr

An investigation ticket as PDFNET-55495 has already been logged in our issue tracking system for this purpose. We have linked it with this forum thread so that you will receive a notification as soon as it is resolved. Please spare us some time.

1 Like

I am looking for details/clarity on the same general topic on the state of AsposePDF and WCAG compliance. I’ve noticed there are a handful of forum posts on WCAG in general but I can’t tell if WCAG is fully supported or if it or some of it is still under development (or at all). Does anyone have clear answers (or links to details) on the following?

  1. Can AsposePDF generate PDF from HTML/CSS that is WCAG compliant?

  2. If AsposePDF HTML-to-PDF does have some WCAG compliance can anyone confirm if any of the following are included?

  • WCAG 1.1 Text Alternatives
  • WCAG 1.3 Adaptable
  • WCAG 1.4 Distinguishable
  • WCAG 2.4 Navigable
  • WCAG 3.1 Readable
  • WCAG 4.1 Compatible

Thank you

@LSAppsCE

The feature is currently under the phase of the investigation. We are afraid that the support for the tags that you have asked has not been implemented yet. However, we have recorded your concerns and updated the ticket information accordingly. We will inform you as soon as it is available. Please be patient and spare us some time.