Implement multiple HTMLOption paramters in DocumentBuilder.InsertHtml for document formatting

Hi,
We are using DocumentBuilder to insert html and have a few formatting issues.
We are currently using DocumentBuilder.InsertHtml(replacementText, HtmlInsertOptions.RemoveLastEmptyParagraph).

We also want to use useBuilderFormatting which would allow us to retain source formatting of the document.

Since, InsertHtml only accepts 2 parameters i.e. replacementText and Options that are used when HTML string is inserted, is it possible for us to implement both, HtmlInsertOptions.RemoveLastEmptyParagraph and useBuilderFormatting in the insertHtml method while generating the document?

Thank you.

@AdawadkarVedant Sure, you can specify both options. You can use code like the following to achieve this:

builder.InsertHtml("<b>This my html</b>", HtmlInsertOptions.UseBuilderFormatting | HtmlInsertOptions.RemoveLastEmptyParagraph); 

HtmlInsertOptions is flags enum, so you can pass several options using | operator.

Hi,
Thanks for the quick response. This has worked for us.

Thank you.

1 Like