Skip to content
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

DocumentAssembler: Text formatting? #70

Closed
Marcel0024 opened this issue Oct 13, 2023 · 7 comments · Fixed by #86
Closed

DocumentAssembler: Text formatting? #70

Marcel0024 opened this issue Oct 13, 2023 · 7 comments · Fixed by #86
Labels
question Further information is requested Word Word related tasks

Comments

@Marcel0024
Copy link

I couldn't find a way to format text in the document assembler. rtf/markdown/html or anything? Am i correct in this?

I'm willing to take a stab at it, with some guidance, does it happen anywhere else in the library that i can look how it should be done?

With some formatting, like bold, italic, underline and list would make this killer library.

@sergey-tihon sergey-tihon added question Further information is requested Word Word related tasks labels Oct 13, 2023
@sergey-tihon
Copy link
Owner

I do not know (because I do not use it much)

But I think that if the placeholder already has styles applied (like bold/italic/underline) then DocumentAssemblier should insert text and preserve styles. Is not it?

@Marcel0024
Copy link
Author

Yes it does. But that's for the whole variable. I want to add a big paragraph and format the text myself. So a long text with bold/italic a few words.

@sergey-tihon
Copy link
Owner

How complicated is your template document? Maybe you can use DocumentBuilder API?

You can generate Word document with arbitrary formatting and then merge multiple documents into one using DocumentBuilder.

https://github.com/sergey-tihon/Clippit/blob/net6/Clippit.Tests/Word/DocumentBuilderTests.cs#L172-L189

@Marcel0024
Copy link
Author

Marcel0024 commented Oct 14, 2023

Nice suggestion, but I don't think it will work. My templates are quite complicated. Users fill in their profile and can generate a Word document out of it with the company styling. So, some paragraphs inside tables need some formatting by the users.

@sergey-tihon
Copy link
Owner

Then I probably have nothing to offer ...

Maybe HtmlToWmlConverter.ConvertHtmlToWml? Generate HTML and convert it to Word? (never used this part of the library myself)

@MalcolmJohnston
Copy link
Contributor

I am looking for a suitable home for a number of improvements that I have made to OpenXmlPowerTools over the years. One of the improvements is to support some inline formatting from HTML, including:

  • Bold
  • Underline
  • Italic
  • Hyperlinks

I would be happy to open a PR here if you have the time to review / merge it?

@sergey-tihon
Copy link
Owner

@MalcolmJohnston Sure, PRs are more than welcome, especially if they are relatively small, keep build green and ideally contain some tests 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Word Word related tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants