push_font method

push_font()

Saves current character formatting onto the stack.

def push_font(self):
    ...

Examples

Shows how to use a document builder’s formatting stack.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
# Set up font formatting, then write the text that goes before the hyperlink.
builder.font.name = 'Arial'
builder.font.size = 24
builder.write('To visit Google, hold Ctrl and click ')
# Preserve our current formatting configuration on the stack.
builder.push_font()
# Alter the builder's current formatting by applying a new style.
builder.font.style_identifier = aw.StyleIdentifier.HYPERLINK
builder.insert_hyperlink('here', 'http://www.google.com', False)
self.assertEqual(aspose.pydrawing.Color.blue.to_argb(), builder.font.color.to_argb())
self.assertEqual(aw.Underline.SINGLE, builder.font.underline)
# Restore the font formatting that we saved earlier and remove the element from the stack.
builder.pop_font()
self.assertEqual(aspose.pydrawing.Color.empty().to_argb(), builder.font.color.to_argb())
self.assertEqual(aw.Underline.NONE, builder.font.underline)
builder.write('. We hope you enjoyed the example.')
doc.save(file_name=ARTIFACTS_DIR + 'DocumentBuilder.PushPopFont.docx')

See Also