We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Insert HTML format

Read a field HTML type and change the type of field letter to “Arial Narrow” and size 9.5 (only the type of letter and size), and keep formats for example Bold, Italic, Underline.

Example
:

- Html
text read: “This is proof text
- Text to be printed: This is a proof text
- Tools: Aspose.Net
- Command: Builder.InsertHtml ()

Best regards.

Hi Rodrigo,

Thanks for your inquiry. We introduced a new overload of DocumentBuilder.InsertHtml method which allows you to choose what formatting will be used as a base for inserted HTML fragments.

The new overload has an argument useBuilderFormatting which when is false, formatting specified in DocumentBuilder is ignored, and formatting of inserted text is based on default HTML formatting. In this case, inserted text looks as in browsers.

When useBuilderFormatting is true, formatting of inserted text is based on formatting specified in DocumentBuilder. Note that useBuilderFormatting chooses only base formatting of inserted text, and do not affect formatting directly specified in the HTML fragment.

The following example illustrates the difference between the two modes:

DocumentBuilder builder = new DocumentBuilder();

builder.ParagraphFormat.LeftIndent = 72;

builder.Font.Name = "Arial";

builder.Font.Size = 24;

bool useBuilderFormatting = ...

builder.InsertHtml("

Text

"
, useBuilderFormatting);

In this example, if useBuilderFormatting is false, the inserted paragraph will have no left indent and will use the 'Times New Roman' 12pt font, which is the default HTML font and indent. If useBuilderFormatting is true, the inserted paragraph will be indented by 1 inch (72 points) and will use the 'Arial' 24pt font, as specified in DocumentBuilder. However, in both cases the inserted text will be bold and red, as specified in the HTML fragment.

So, please try using this method as follows:

builder.InsertHtml("Some text before ", true);


Hope this helps you. Please let us know if you have any more queries.

Thanks for the reply,

It’s work!

Best regards.
Rodrigo Melgarejo

Hi Rodrigo,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.