MigraDoc - Get Pages Number
Asked Answered
L

1

5

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

Lachellelaches answered 2/9, 2014 at 22:23 Comment(0)
E
8

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

Eucalyptus answered 3/9, 2014 at 7:50 Comment(2)
Ok. I have class which rewrite numbers as words. I need to get some int value as number of pages to convert it to words. I realized that I have to render the document in a stream of MigraDoс, received at the same time the number of pages to execute a method svoeg class, and then open the document from a stream in PDFSharp and add a single line? Sorry for EnglishLachellelaches
After rendering, open the PDF with PDFsharp and PDFsharp will have the page count. The Watermark sample shows how to modify existing pages, the Text Layout sample shows how to draw text. Using MemoryStreams will make this more efficient. Samples page: pdfsharp.net/wiki/PDFsharpSamples.ashxEucalyptus

© 2022 - 2024 — McMap. All rights reserved.