This is a migrated thread and some comments may be shown as answers.

Update a TOC and fields before converting a RadFlowDocument to PDF

1 Answer 205 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stéphane
Top achievements
Rank 1
Stéphane asked on 28 May 2015, 05:00 PM
Hello,

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!

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 01 Jun 2015, 04:54 PM
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);
editor.DrawText(count.ToString());
}

I hope this is useful.

Regards,
Petya
Telerik
Tags
General Discussions
Asked by
Stéphane
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or