2020-12-06 12:05 阅读 0

Styling hyperlink

Is it possible yet to style a Hyperlink with TextRun-styles, like calling .bold() ?

var doc = new Document();
var paragraph = new Paragraph();
var link = doc.createHyperlink('http://www.example.com', 'Hyperlink');

I'm writing in browser and try to convert user-generated input from an RTE.


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

4条回答 默认 最新

  • weixin_39886172 weixin_39886172 2020-12-06 12:05

    I will look into this when I get home

    点赞 评论 复制链接分享
  • weixin_39886172 weixin_39886172 2020-12-06 12:05


    here you go

    Essentially you add the hyperlink in a paragraph, then you can style it as per usual

    点赞 评论 复制链接分享
  • weixin_39714191 weixin_39714191 2020-12-06 12:05

    So there's no easy way to just call .bold or similar, right? Usecase is translation of a frontend-website with RTE-Editor and including that in a docx, and as styling works on inline-element basis, either <span style="font-weight=bold"></span> or <strong></strong>, styling individual text-runs is more appropriate than paragraphs. The docx-output is meant as a more flexible output so the user can be creative and adapt the output-file how he wants, so if it's not possible yet, that's fine.

    点赞 评论 复制链接分享
  • weixin_39886172 weixin_39886172 2020-12-06 12:05

    Ok I did some digging, and it is not yet possible

    There's no way to apply styles to Paragraphs or Hyperlinks, only TextRuns at the moment

    Will do this in future

    点赞 评论 复制链接分享