sergey-tihon / Clippit

Fresh PowerTools for OpenXml
https://sergey-tihon.github.io/Clippit/
MIT License
50 stars 19 forks source link

DocumentAssembler: Text formatting? #70

Open Marcel0024 opened 1 year ago

Marcel0024 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 3 months ago

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:

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

sergey-tihon commented 3 months ago

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