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

Add Html to a PDF document


Product Version 2021.3.1109 Author
Product RadPdfProcessing Dimitar Karamfilov


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


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.

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"); 
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

In this article