-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change default font type and font size #72
Comments
I think currently there's no support for that. In the mean time, you can use a custom template where you define the default font for your document. https://github.com/karnov/htmltoword#configure-templates-and-xslt-paths. |
Thank you, but I am not sure how to use them (I tried). Do I have to create empty docx and point it there? |
It depends on your application, if it's a rails application you can have it in somewhere like
|
So for the time being we are stuck with one font and size for the entire document? |
Been trying to work this out, but seems like even with the path custom_templates_path created an initializer: config/initializers/htmltoword.rb
"Template path: /lib/assets/templates/new_template.docx"
it opens in word. Even though this new_template.docx has overridden all fonts with Times New Roman it still creates a document with Arial for all text. Seems like the custom template is not working. Also if I just update the default.docx in the gem to be Times New Roman it still generates a doc with Arial |
any solution here? |
I'm seeing the same issue - can't get htmltoword to use the template Word file I supply (via Rails 5.2). Has anyone actually got the templates to work or is it a universal problem? I tried setting the paths in an initializer and, although this seems to work (the path is redefined), the I tried using the word_template option in the actual command with no effect (except that Rails complains if the file isn't there, of course, so I know the path is correct):
Is the only option to work out how to redefine the styles in the WordXML and rebuild the gem with my preferred styles? Has anyone tried this? |
I just did the following, which worked:
|
Ah - thanks, @joshudev. The missing step for me was the last one: I'd tried in various ways to replace the default template and failed. Making an explicit template and referring to it at the point of generating the file gives me a file formatted as I wanted! |
How can I change font size and font type? I am losing my mind, whatever I do, it is always Arial 9pt.
I tried
body { font-family: "Times New Roman", Times, serif; font-size:16px; font-weight:600 }
`
<w:p>
<w:r>
<w:rPr>
<w:sz w:val="50"/>
<w:rFonts w:ascii="Times New Roman" />
</w:rPr>
<w:t xml:space="preserve">This paragraph is Times New Roman at 25pt</w:t>
</w:r>
</w:p>
Some text
` And nothing works :(The text was updated successfully, but these errors were encountered: