New to Telerik Document ProcessingStart a free 30-day trial

Add Html to a PDF document

Updated on Feb 19, 2026

Environment

Product Version2021.3.1109Author
ProductRadPdfProcessingDimitar Karamfilov

Description

You have an HTML that needs to be converted to PDF or added to an existing document.

Solution

You can use the WordsProcessing library to convert the content to a RadFlowDocument and then insert it to the existing document along with other content.

csharp
HtmlFormatProvider provider = new HtmlFormatProvider();
var htmlConteont = provider.Import(File.ReadAllText(@"..\..\HtmlPage1.html"));

RadFlowDocument document = new RadFlowDocument();
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);

editor.InsertText("Sample Content");
editor.InsertParagraph();

var options = new InsertDocumentOptions();
options.ConflictingStylesResolutionMode = ConflictingStylesResolutionMode.UseTargetStyle;
editor.InsertDocument(htmlConteont, options);
 
editor.InsertText("Content After");

var pdfFProvider = new PdfFormatProvider();
var pdfBytes = pdfFProvider.Export(document);
File.WriteAllBytes("result.pdf", pdfBytes); 

See Also