Update a TOC and fields before converting a RadFlowDocument to PDF

2 posts, 0 answers
  1. Stéphane
    Stéphane avatar
    5 posts
    Member since:
    Apr 2015

    Posted 28 May 2015 Link to this post


    We create a RadFlowDocument with a table of contents and some fields (page, numpages). We want to convert it to PDF, but the table of contents and fields are not updated in the PDF, even though I have executed the UpdateFields method before. How can I proceed?

    Thank you for your help!
  2. Petya
    Petya avatar
    990 posts

    Posted 01 Jun 2015 Link to this post

    Hello Stéphane,

    RadWordsProcessing doesn't genuinely support most types of fields and cannot update them in the document. The feature is in our backlog and you can vote for its implementation through the public portal: Table of Contents FieldPage Numbering Fields - PAGE, NUMPAGES

    In the meantime it is possible to create a field with WordsProcessing and export the document to DOCX, but you'd need to depend on the consumer (e.g. MS Word or another word processor) to update its values.

    Until this functionality is implemented you could try calculating the values of the fields after the document has been exported to PDF format and drawing them. For example, try using the ExportToFixedDocument() method of the PdfFormatProvider and draw page numbers on each page of the fixed document like this:
    var provider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
    RadFixedDocument fixedDocument = provider.ExportToFixedDocument(flowDocument);
    int count = 0;
    foreach (var page in fixedDocument.Pages) {
    count += 1;
    FixedContentEditor editor = new FixedContentEditor(page);
    editor.Position.Translate(10, 10);

    I hope this is useful.

Back to Top