Domanda

I'm currently using XDocReport 1.0.3 to generate Reports in docx format. When using it with SyntaxKind.HTML I can not get the used font family to be displayed properly in the output document. I figured that there are basically 2 different approaches.

  • Input: Some arbitrary HTML provided by the user using CKEditor.
  • Template Input: .docx template
  • Output .docx File

a) Set the font directly in the template that is beeing used. Result is that the font is not recognized and it falls back to the default (here Times New Roman).

b) Set the font-family in the HTML that is being the input data for the document. This doesn't work either and also falls back to the default (Times New Roman).

Is anybody out there that figured how to fix that issue? I'm also going to send a bug report to the XDocReport developers. And reference the response here if any.

È stato utile?

Soluzione

We found somewhat of a workaround to this issue. For paragraphs with input proivded by fields of type SyntaxKind.HTML the reporter falls back to the "Standard" template in docx for that paragraph. So the trick is, to adjust the template for "Standard" and set font and styling there. I do only have a german version of Word. Here it is "Formatvorlagen". Maybe this helps someone. It's not ideal, but we got around with it.

Altri suggerimenti

HTML text styling with docx doesn't manage font. Text styling was created to manage commons styles like bold, italic, with HTML, Markdown, wiki, etc syntax and not to convert perfectly HTML to docx.

But it seems more and more people wish to use HTML text styling with advanced styles (like design HTML table), so we improve HTML text styling on each version of XDocReport.

Please read Supported styles for docx to know which HTML tags you can use.

I suggest you to create issues here by attaching a simple Java main & docx with your case. But I think html text styling with font is not an easy topic.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top