rendering html fragaments in a PDF

1 Answer 90 Views
PdfProcessing
Edo
Top achievements
Rank 1
Edo asked on 26 Apr 2023, 09:26 AM | edited on 26 Apr 2023, 11:15 AM

Hello

We have an existing extensive report created with a RadFixedDocument for saving as pdf. We would like to allow users to add content from multiple TelerikEditors to the report, as comments. The TelerikEditor exports html. I have seen this post: https://www.telerik.com/forums/telerik-blazor-pdf-processing---tutorial-on-how-to-add-markup-html-in-a-string-to-a-pdf

Is there any other way to add HTML snippets in a PDF report, or should we rewrite the entire report as a RadFlowDocument?  Is there an other way to convert some basic HTML to elements we can use on Block.

Thanks

  -Edo

 

1 Answer, 1 is accepted

Sort by
1
Yoan
Telerik team
answered on 26 Apr 2023, 10:59 AM

Hello Edo,

Currently, the options provided in the shared post remain the most optimal. One additional approach I can add is converting HTML to PDF and then merging the result document with the main PDF file.

HtmlFormatProvider htmlFormatProvider= new HtmlFormatProvider();
PdfFormatProvider pdfFormatProvider = new PdfFormatProvider();

RadFixedDocument initialPdfDocument = new RadFixedDocument();

RadFlowDocument htmlContent = htmlFormatProvider.Import(html);
RadFixedDocument htmlPdf = pdfFormatProvider.ExportToFixedDocument(htmlContent);

initialPdfDocument.Merge(htmlPdf);

And in case you decide to take the RadFlowDocumentt approach, HTML snippets can be converted to a document and then imported as elements of another RadFlowDocument by utilizing the DocumentElementImporter. Here are some additional articles that can give you more details in case you decide to take that route:

Hope this helps.

Regards, Yoan Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
PdfProcessing
Asked by
Edo
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or