MemoryStream Webpage HTML to PDF

2 posts, 0 answers
  1. Alex Tushinsky
    Alex Tushinsky avatar
    52 posts
    Member since:
    Feb 2006

    Posted 01 Oct 2015 Link to this post


    I am writing a very specific type of a report, which I have to control line height, dynamically generate content, and fill in a chart object.  I'm currently doing this using OpenXML and Microsoft Word.  When created, the end result is exported into PDF.  This always seemed like overkill for me, and I would have preferred to use Telerik Reporting, except that Reporting doesn't let me set specific line heights.

    In any case, I would like to try to dynamically build a web page of the report that I'm doing, which would be formatted exactly as I need it to be, and would also incorporate a RadChart.  I would like to use either WordsProcessing or PDFProcessing to take the MemoryStream of this HTML page, and output it to PDF.  Is this possible?  I don't see any specific examples, although I see there is a conversion demo which can take HTML as input and create a PDF as output.

    Thank you,

  2. Boby
    Boby avatar
    637 posts

    Posted 05 Oct 2015 Link to this post

    Hello Alex,

    I will list some options and limitations and will leave the decision on how to proceed to you:

    - Create an HTML page with the report data and use directly the ClientExportManager to export it to PDF. Not sure if this would work for you, as the page should be rendered in the browser.

    - Create HTML or other flow format (docx, RTF) with the report data, import it with RadWordsProcessing to produce an instance of RadFlowDocument, and then export to PDF using the PdfFormatProvider. Note that each conversion has some limitations, as all of the formats are extremely complex and we support only a subset of them. Here you can decide to skip the importing and create the RadFlowDocument from scratch, using the rich document model or the RadFlowDocumentEditor helper class (or a combination of both).

    - You can use directly RadPdfProcessing to generate the PDF document from scratch. As building a document with text can be inconvenient with the fixed model (e.g. you have to split the text to lines by yourself) you can use the RadFixedDocumentEditor utility class, which provides a convenient way to generate fixed content in a flow-like manner. 

    Also, note that currently charts are not supported from RadWordsProcessing document model, so the import operations will skip them from any of the available flow formats.

Back to Top