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

Free Support Forum - aspose.com

Aspose.Word For Java word转html下划线类型问题

我有一个word文件,里面有一些文字下方是下划线,类型不同。但是转成html后,都显示为普通的下划线Test.zip (19.4 KB)

@590smile, 感谢您报告此问题。 它已被记录为 WORDSNET-23587。 修复后,您将收到通知。

谢谢。
还有其它两个问题
1.word插入带有波浪线的html,保存为doc或者pdf时。也会变成直线,而非波浪线。
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
html = “<span style=“text-decoration: underline;text-decoration-style: wavy;”>波浪线”
builder.insertHtml(html);
2.设置着重号,保存为pdf时不会显示着重号
run.getFont().setEmphasisMark(4);

@590smile,

  1. Aspose.Words 不支持 text-decoration-style 属性。 Aspose.Words 仅支持 CSS2 属性,但 CSS3 中引入了 text-decoration-style。 Aspose.Words 支持 CSS2 中定义的 text-decoration 属性

  2. 这是一个已知问题,它在我们的 bugtracker 中记录为 WORDSNET-23147。 解决后,将通过论坛通知您。

请问目前有没有其它方法可以设置着重号的,导出成pdf时展示

您好 @590smile,

您可以尝试用形状替换着重号。 请看下面给出的示例:

    public static void main(String[] args) throws Exception {
        License lic = new License();
        lic.setLicense("Aspose.Words.Java.lic");

        Document doc = new Document("inWithEmphasisMarks.docx");
        DocumentBuilder builder = new DocumentBuilder(doc);

        // Find all runs with emphasis marks.
        NodeCollection runs = doc.getChildNodes(NodeType.RUN, true);
        for (Run run : (Iterable<Run>) runs)
        {
            if (run.getFont().getEmphasisMark() == EmphasisMark.OVER_SOLID_CIRCLE)
            {
                // Turn off the emphasis for the run characters.
                run.getFont().setEmphasisMark(EmphasisMark.NONE);
                // Replace emphasis marks with shapes.
                CreateEmphasisShapeMark(builder, run);
            }
        }

        doc.save("outWithEmphasisMarkShapes.docx");

        doc.updatePageLayout();
        doc.save("outWithEmphasisMarkShapes.pdf");
    }

    private static void CreateEmphasisShapeMark(DocumentBuilder builder, Run run) throws Exception {
        String emphasisMarkChar = "\uFF0E";
        double fontSize = run.getFont().getSize();
        double leftPosition = fontSize * 1.3;
        double topPosition = fontSize / 3;

        builder.moveTo(run);
        Shape textBoxShape = builder.insertShape(ShapeType.TEXT_BOX, fontSize, fontSize);

        textBoxShape.setRelativeHorizontalPosition(RelativeHorizontalPosition.CHARACTER);
        textBoxShape.setRelativeVerticalPosition(RelativeVerticalPosition.LINE);
        textBoxShape.setLeft(leftPosition);
        textBoxShape.setTop(topPosition);
        textBoxShape.isLayoutInCell(false);
        textBoxShape.setStroked(false);
        textBoxShape.setBehindText(true);
        textBoxShape.setWrapType(WrapType.NONE);

        TextBox textBox = textBoxShape.getTextBox();
        textBox.setFitShapeToText(true);
        textBox.setTextBoxWrapMode(TextBoxWrapMode.NONE);
        textBox.setInternalMarginBottom(0);
        textBox.setInternalMarginLeft(0);
        textBox.setInternalMarginRight(0);
        textBox.setInternalMarginTop(0);

        builder.moveTo(textBoxShape.getLastParagraph());
        builder.getFont().setSize(fontSize);
        builder.write(emphasisMarkChar);
    }

files.zip (39.6 KB)