How to add the font size of text annotations beyond the available values in WPF PdfViewer
In the WPF PDF Viewer a default font properties dialog is available for text annotations, which includes a font size combo box with a range of preset font sizes. At the sample level, you can add a custom font size for text annotations by handling the PDF Viewer Loaded
event and including the custom size as an option in the font size combo box within the font properties dialog.
The combo box within the font properties dialog has been accessed, and a custom font size has been added as text to the combo box items.
Steps to add the font size of text annotations beyond the available values using C#
The below steps illustrate how to add the font size of text annotations beyond the available values in WPF PdfViewer.
Step 1: Wire the loaded event of PDF Viewer in the constructor of the main window class.
C#
pdfViewer.Loaded += pdfViewer_Loaded;
Step 2: In the loaded event, you can add a custom font size as an option in font size combo box within the font properties dialog.
- Retrive the font properties dialog using its template name.
- Retrive the instance of the font size combo box using its template name.
- Add a custom font size as text to combo box items.
C#
private void pdfViewer_Loaded(object sender, RoutedEventArgs e)
{
// Get the instance of the FontPropertiesDialog using its template name.
FontPropertiesDialog propertiesDialog = pdfViewer.Template.FindName("PART_FreeText", pdfViewer) as FontPropertiesDialog;
// Get the instance of the font size combo box using its template name.
ComboBox fontSize = (ComboBox)propertiesDialog.Template.FindName("FontSizeMenu", propertiesDialog);
//Add a custom font size as string to combo box items.
fontSize.Items.Add("24");
fontSize.Items.Add("26");
fontSize.Items.Add("28");
fontSize.Items.Add("36");
fontSize.Items.Add("48");
fontSize.Items.Add("72");
}
A complete working sample to add the font size of text annotations beyond the available values in WPF PdfViewer can be downloaded from GitHub.
Conclusion
I hope you enjoyed learning about how to add the font size of text annotations beyond the available values in WPF Pdf Viewer Control.
You can refer to our WPF PDF Viewer page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!