This sample shows how to customize text appearance in PDF documents using Docotic.Pdf library.
You can use Document.TextStyleWithFont methods to create a text style for a custom font. Or you can start with the TextStyle.Parent to customize some settings of a parent or default text style.
Use TextStyle methods to get the desired text appearance. You can change font size, color, letter spacing, and so on.
Layout elements allow you to apply text style using these methods:
- PageLayout.TextStyle
- LayoutContainer.TextStyle
- TextContainer.Style
- TextSpan.Style
- TextPageNumber.Style
This sample applies the root
style to all page elements. This style applies the red font color and inherits
other settings from library defaults. Find the default values in the documentation for the TextStyle.Parent
property.
The text in the page header inherits root
style from the page layout settings. However, the code changes the style of the the "superscript" word.
The page content contains a text container that uses the child
style. This style inherits the font size
from the root
style, overrides the font color to blue and sets a few other style properties.
The "Child style" line in the text container uses this child
style. And the "Custom style" line uses
the custom
style. This style uses custom font with explicitly set additional properties.
This sample code uses free Docotic.Pdf.Layout add-on for Docotic.Pdf library.