New to Telerik Document Processing? Download free 30-day trial

Inserting XAML Content into a PDF Document


Version Product Author
2024.2.426 RadWordsProcessing Desislava Yordanova


There are use cases in WPF applications that collect input from a RichTextBox and then save it as an XAML string. This input could include links, font styles (bold, italic), bullet points, tables, etc. Then, having this piece of XAML content, the required functionality is to import it into an existing PDF document. This article demonstrates a sample approach how to handle such a scenario with the help of Telerik Document Processing Libraries.


The XamlFormatProvider is applicable for the WPF RadRichTextBox control. It is important to note that the format providers offered by the RichTextBox control are different than the format providers from the Document Processing Libraries. Hence, they may support different features that may produce different output results.

To insert XAML content into a PDF while retaining formatting, follow these steps:

  1. Export the XAML content from the RadRichTextBox to a DOCX format using the DocxFormatProvider.

  2. Utilize the RadWordsProcessing library to import the DOCX file.

  3. The DOCX content can then be exported to a PDF format, preserving the content formatting as closely as possible.

  4. If you need to merge the newly created PDF content (from the XAML content) with another PDF document, use the PdfStreamWriter for merging the documents.

The XAML SDK repository on GitHub contains examples showing the capabilities of PdfStreamWriter. The Manipulate Pages example shows different use cases of PdfStreamWriter. Have a look at the MergeDifferentDocumentsPages method.

See Also

In this article