0
votes

I wanted to find a way to set the document level properties in MigraDoc. For example I want to set all margins (top, left, right, bottom) to 5 or want to set the font for whole PDF document once. I don't want to set them in each section or paragraph. I know I can set them in sections but my document will have three different sections (header, contents and footer) therefore it is very annoying to repeat the same code for setting same properties in each section.

Moreover, I have set top margin to 5 for header section however top margin seems to be more than 5 (looks like at least 10). Thanks for help.

1
therefore it is very annoying to repeat the same code for setting same properties in each section. - you can put such code in a separate method called for each section.mkl

1 Answers

0
votes

Margins set for the first section are inherited by the following sections. If you need the same margins for all sections, only set them for the first section.

Use a Style to set the font. Many styles are set by default (like in word), but you can add more styles as needed.

All styles are derived from the Normal style. Set the font for Normal only to change the font for the complete document.

To use a different style, specify its stylename at the paragraph.

See also:
http://pdfsharp.net/wiki/HelloMigraDoc-sample.ashx
(and the other samples)

Re Top Margin: some fonts reserve space for an ascender (accents, diacritical marks, ...) that may make the top margin look bigger than it is.