public void PushPopFont()
{
//ExStart
//ExFor:DocumentBuilder.PushFont
//ExFor:DocumentBuilder.PopFont
//ExFor:DocumentBuilder.InsertHyperlink
//ExSummary:Shows how to use temporarily save and restore character formatting when building a document with DocumentBuilder.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Set up font formatting and write text that goes before the hyperlink.
builder.Font.Name = "Arial";
builder.Font.Size = 24;
builder.Font.Bold = true;
builder.Write("To go to an important location, click ");
// Save the font formatting so we use different formatting for hyperlink and restore old formatting later.
builder.PushFont();
// Set new font formatting for the hyperlink and insert the hyperlink.
// The "Hyperlink" style is a Microsoft Word built-in style so we don't have to worry to
// create it, it will be created automatically if it does not yet exist in the document.
builder.Font.StyleIdentifier = StyleIdentifier.Hyperlink;
builder.InsertHyperlink("here", "http://www.google.com", false);
// Restore the formatting that was before the hyperlink.
builder.PopFont();
builder.Writeln(". We hope you enjoyed the example.");
doc.Save(MyDir + @"\Artifacts\DocumentBuilder.PushPopFont.doc");
//ExEnd
}