Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MigraDoc - Get Pages Number

How I can get the number of pages before rendering? I need to write the number as words in my document.

like image 910
Blackbee Avatar asked Sep 02 '14 22:09

Blackbee


1 Answers

For page numbers as numbers:
You don't have to get the number, you can add placeholders (called Fields) to your document and MigraDoc will insert the page numbers automatically while rendering the document.

See AddPageField() in this sample:
http://pdfsharp.net/wiki/HelloMigraDoc-sample.ashx

Other field functions are AddNumPagesField(), AddSectionField(), AddSectionPagesField(), AddDateField(), and AddPageRefField(string name)

For page numbers as words:
There is no built-in solution to get page numbers as words.

Where do you need the page numbers? It is possible to have MigraDoc create a document without page numbers and then use PDFsharp to add the page numbers as words in either the header or the footer. If you need page numbers as references within the text then I don't have an easy answer.

See also:
http://forum.pdfsharp.net/viewtopic.php?p=8476#p8476

like image 167
I liked the old Stack Overflow Avatar answered Sep 22 '22 16:09

I liked the old Stack Overflow