I have some trouble converting a html document to pdf where images etc. is accessible from a program like NVDA (NV Access | Download NVDA). I’m using Aspose with .NET 5.
I have made a small example where I’m creating a simple html-string with images that have an alt text and converting it to a byte[].
Code:
var temp = @"<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<figure class=""image"" contenteditable=""false""><img src=""https://media.istockphoto.com/photos/hot-air-balloons-flying-over-the-botan-canyon-in-turkey-picture-id1297349747?b=1&k=20&m=1297349747&s=170667a&w=0&h=oH31fJty_4xWl_JQ4OIQWZKP8C6ji9Mz7L4XmEnbqRU="" alt=""A random bird BOBBY BOBBY BOOBY"" width=""366"" height=""366""></figure>
<p>My second paragraph.</p>
<img src=""https://media.istockphoto.com/photos/hot-air-balloons-flying-over-the-botan-canyon-in-turkey-picture-id1297349747?b=1&k=20&m=1297349747&s=170667a&w=0&h=oH31fJty_4xWl_JQ4OIQWZKP8C6ji9Mz7L4XmEnbqRU="" alt=""A random bird gives an alt text"" width=""366"" height=""366"">
</body>
</html>";
byte[] bytes = Encoding.ASCII.GetBytes(temp);
MemoryStream htmlStringStreamTemp = new MemoryStream(bytes);
htmlStringStreamTemp.Position = 0;
Aspose.Pdf.HtmlLoadOptions htmlLoadOptionsTemp = new Aspose.Pdf.HtmlLoadOptions();
Document htmlDocumentTemp = new Document(htmlStringStreamTemp, htmlLoadOptionsTemp);
var pdfDocumentTemp = new Document();
pdfDocumentTemp.Pages.Add(htmlDocumentTemp.Pages);
pdfDocumentTemp.Save(@"C:\Temp\temp03.pdf");
var options = new PdfFormatConversionOptions(PdfFormat.PDF_A_2A);
options.ErrorAction = ConvertErrorAction.Delete;
pdfDocumentTemp.Convert(options);
pdfDocumentTemp.Save(@"C:\Temp\temp04.pdf");
Can you see what I’m doing wrong or if you don’t support this feature yet?