Vertical Text in HTML Not Translated To Word Table


#1

When an HTML source file contains a table which has text formatted to be rotated vertically, the format is ignored when the HTML is inserted via DocumentBuilder.

To reproduce this behavior:

  1. Copy the attached HTML source file “VerticalText.html” to the file system…
  2. Use the sample code below to generate a new Word document which inserts the given HTML via the DocumentBuilder.insertHtml API.
  3. Examine the generated document and notice that the cell with vertical text has horizontal alignment.

Notes:

  • If you preview the HTML in any major browser, you can see it will show a text heading to be vertically formatted
  • It’s clear that Aspose Words supports vertical text in cells via the TextOrientation class, but for some reason, this is not applied when the insertHtml API is used.
  • The sample code was tested on the latest Aspose Words version 17.7.

Sample Code:

 public static void verticalTextHtml() {
    // add full path as necessary
    final String htmlSrc = "VerticalText.html";
    try {

       // create new blank document
       Document wdDoc = new Document();
       DocumentBuilder builder = new DocumentBuilder(wdDoc);

       // load the html
       final String html = new String(Files.readAllBytes(Paths.get(htmlSrc)));

       // add the paragraph to the document
       Paragraph para = builder.insertParagraph();
       builder.moveTo(para);
       // insert the HTML into the doc - keep HTML formatting intact
       builder.insertHtml(html, false);

       wdDoc.save(htmlSrc.replace(".html", ".docx"));
       System.out.println("Saved Document: " + htmlSrc.replace(".html", ".docx"));

    } catch (Exception ex) {
       ex.printStackTrace();
    }
 }

Attachment:
VerticalText.zip (3.2 KB)

Thanks.


#2

@oraspose

Thanks for your inquiry. We have tested the scenario and noticed the reported issue. So we have logged a ticket WORDSNET-15759 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.