We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

insertHtml IMG ALT Tag

Hello


I am looking to import html content from WYSIWYG editor into the documentbuilder.inserthtml function.

In the WYSIWYG editor content, it will consists of IMG tag with ALT attribute.

On document.save (DOCX), Aspose.words will preserve the ALT tag.

On the other hand, on document.save (PDF), Aspose.words loses the ALT tag. Any ideas how we can maintain the ALT tag?

Thanks
Hi,

Thanks for your inquiry.

While using the latest version of Aspose.Words i.e. 17.2.0, we managed to reproduce this issue on our end. We have logged this issue in our bug tracking system. The ID of this issue is WORDSNET-14931. Your thread has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,

Hi,


Please set PdfSaveOptions.ExportDocumentStructure. Then Aspose.Words will output ALT tag to PDF the same way as MS Word does. Please see attached documents and following code.

Document doc = new Document(MyDir + @“HTMLPage1.html”);

PdfSaveOptions opts = new PdfSaveOptions();

opts.ExportDocumentStructure = true;

doc.Save(MyDir + @"17.2.0.docx");

doc.Save(MyDir + @"17.2.0.pdf", opts);


Hope, this helps.

Best regards,
Afternoon

Thank you for getting back to me. I have tested the following code with the latest Aspose version and it is still not show the ALT tag in PDF. It does show the ALT tag in DOCX.

See PDF and DOCX attached files generated from the code below:


Document document = new Document(new FileInputStream("abc.htm"));
PdfSaveOptions opts = new PdfSaveOptions();
opts.setExportDocumentStructure(true);
DocumentBuilder templateDocBuilder = new DocumentBuilder(document);
//Set document title
document.getBuiltInDocumentProperties().setTitle("");

templateDocBuilder.insertHtml("First Line

Google Logo

Last Line");
document.updateFields();

document.save("abc.docx");
document.save("abc.pdf");

Afternoon


Just tested with the OPTS attribute and it does show the ALT attribute in PDF.

Thank you so much for the assistance.
Hi,

It is great you were able to resolve this issue on your end. Please let us know any time you have any further queries.

Best regards,