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

Text alignment in Footer

1 Answer 526 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Khawar
Top achievements
Rank 1
Khawar asked on 21 Feb 2019, 04:06 PM

Hi, 

I m trying to make footer right justify but unable to find any reference for this scenario. Here is my code

Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider formatProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
    int numberOfPages = formatProvider.ExportToFixedDocument(doc).Pages.Count;
    RadFlowDocumentEditor editor = new RadFlowDocumentEditor(doc);
    editor.MoveToParagraphStart(doc.Sections(0).Footers.Add().Blocks.AddParagraph());
    editor.InsertText("Page  ");
    editor.InsertField("PAGE", "Page number will be evaluated on each page footer.");
    editor.InsertText(" of ");
    editor.InsertField("NUMPAGES", numberOfPages.ToString());

Any help would be greatly appreciated.

1 Answer, 1 is accepted

Sort by
1
Tanya
Telerik team
answered on 26 Feb 2019, 08:54 AM
Hello Khawar,

To align the content in the footer to the right, you can use the properties of the Paragraph class. Here is how I changed the code you shared to achieve that:
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider formatProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
int numberOfPages = formatProvider.ExportToFixedDocument(document).Pages.Count;
editor = new RadFlowDocumentEditor(document);
editor.ParagraphFormatting.TextAlignment.LocalValue = Alignment.Right;
Paragraph footerParagraph = document.Sections[0].Footers.Add().Blocks.AddParagraph();
footerParagraph.TextAlignment = Alignment.Right;
editor.MoveToParagraphStart(footerParagraph);
editor.InsertText("Page  ");
editor.InsertField("PAGE", "Page number will be evaluated on each page footer.");
editor.InsertText(" of ");
editor.InsertField("NUMPAGES", numberOfPages.ToString());

Hope this is helpful.

Regards,
Tanya
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
WordsProcessing
Asked by
Khawar
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Share this question
or