PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

some noob questions [SOLVED]
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2373
Page 1 of 1

Author:  Rahvin [ Tue Mar 19, 2013 2:33 pm ]
Post subject:  some noob questions [SOLVED]

Hi,

I'm using MigraDoc for the first time and of course I have some questions ;).

1. I like to create a header with two different texts in the same line.
One text is a changing value from our database and should be left aligned and the other
text is constand and should be right aligned and use another font. How can I do this (not the db-stuff only the printing of two differntly formated texts in the same line ;))?

2. The main body of my document contains a table (Table table = section.AddTable();)
This table seems to be centered on all pages but I want it to be aligned to the top.
How can I achieve this?

Many thanks in advance :).

Author:  Thomas Hoevel [ Wed Mar 20, 2013 9:53 am ]
Post subject:  Re: some noob questions

Hi!

Re 1:
Remove all tab stops, then add a single right-aligned tab stop for the right edge. Then use a single paragraph, add the left-aligned text, a tab stop, then the right-aligned text.
This works fine as long as the whole text fits a single line (use AddFormattedText to have differing formats).

Re 2:
Tables are top-aligned. Check the top margin of your section.

Author:  Rahvin [ Wed Mar 20, 2013 3:17 pm ]
Post subject:  Re: some noob questions

Hi and thanks for you answer.

1.
Could you please post some code? I don't quite understand what you mean.
This is my code so far:
Code:
         
                    Paragraph pa = new Paragraph();
                    pa.Add(new Text(p.Hersteller));
                    pa.Format.Font.Size = 10;
                    pa.Format.Font.Bold = true;

                    section.Headers.Primary.Add(pa);


2. Ok, it works now. It seemed to be an issue with some table-row-blocks I kept together with KeepWith

Author:  Thomas Hoevel [ Wed Mar 20, 2013 4:17 pm ]
Post subject:  Re: some noob questions

Here's a code snippet that adds the text:
Code:
paragraph = section.Footers.Primary.AddParagraph();
FormattedText ft = paragraph.AddFormattedText("AppName", TextFormat.Bold);
ft.Font.Size = 6;
paragraph.AddTab();
paragraph.AddPageField();
paragraph.AddTab();
ft = paragraph.AddFormattedText("More info (bold) " + ApplicationSettings.Berichtsjahr, TextFormat.Bold);
ft.Font.Size = 6;
ft = paragraph.AddFormattedText(" and more info (not bold)", TextFormat.NotBold);
ft.Font.Size = 6;

We use three tab stops.

The code that sets the tab stops:
Code:
Style style;
style = document.Styles[StyleNames.Footer];
style.ParagraphFormat.TabStops.Clear();
style.ParagraphFormat.AddTabStop(center.ToString(CultureInfo.InvariantCulture) + "cm", TabAlignment.Center);
style.ParagraphFormat.AddTabStop(paperwidth.ToString(CultureInfo.InvariantCulture) + "cm", TabAlignment.Right);


You don't need the "center" tab stop, so only use a single AddTab().

Author:  Rahvin [ Fri Mar 22, 2013 11:16 am ]
Post subject:  Re: some noob questions

Vielen Dank :)!

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/