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

Left and Right Alignment in 1 line.
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4303
Page 1 of 1

Author:  Deligo [ Sat Nov 27, 2021 6:47 pm ]
Post subject:  Left and Right Alignment in 1 line.

So I'm using AddTabStop to align the second Text on the right side but there is something extra I want since the result its not the best

1. Set max width on the Left Text so in gets smaller, I know I can use RightIndent but then the right text wont go on the right position fully but stop in the Indent.
2. I simply want the right text to always Align on the Top also not in the bottom.
Check images below

I already have done this with drawlines but I had to recreate everything since new pages are not generated automatically. So I desiced to use PDFsharp & MigraDoc

The width is the PDF printer width but I think I have to calculate it different cause its bigger than the printers page width.
Code:
var s = section.AddParagraph(name, "Normal");
s.Format.TabStops.AddTabStop(width - 10, MigraDoc.DocumentObjectModel.TabAlignment.Center);
s.AddTab();
s.AddText(price);


The one I created with drawline and MeasureString. But I have to rewrite everything to count for the new page generation. Maybe I can use it the document graphics with MigraDoc?
Image

The one I made with MigraDoc I need to make it like the one I made with Drawlines
Image

It also can help if you could tell me a method to know when to generate a new page.
The one I though is make stringbuilder and count each line with measure string. When the Y of the string position is higher than the page height and cant fit make a new page.
But to count each line when string doesnt fit I have to measure it again and again so I got to split it in lines.
Like how MigraDoc knows when to change the page? It measures the string like I thought of doing?

Author:  TH-Soft [ Mon Nov 29, 2021 8:20 am ]
Post subject:  Re: Left and Right Alignment in 1 line.

Hi!

For PDFsharp: If you use the same style for all text then you can use the TextFormatterEx2 class to find page breaks.
viewtopic.php?f=8&t=3192

If you use MigraDoc, consider using a table without visible borders. Left column for the text, right column for the amount.
Tab stops and line breaks do not work together.

Author:  Deligo [ Mon Nov 29, 2021 10:33 pm ]
Post subject:  Re: Left and Right Alignment in 1 line.

TH-Soft wrote:
Hi!

For PDFsharp: If you use the same style for all text then you can use the TextFormatterEx2 class to find page breaks.
viewtopic.php?f=8&t=3192

If you use MigraDoc, consider using a table without visible borders. Left column for the text, right column for the amount.
Tab stops and line breaks do not work together.


Could you please show me an example of table that has a text on the left with a specific width and 1 on the right that aligns on the top or also on the center of the left height column

Author:  TH-Soft [ Mon Nov 29, 2021 10:36 pm ]
Post subject:  Re: Left and Right Alignment in 1 line.

Deligo wrote:
Could you please show me an example of table that has a text on the left with a specific width and 1 on the right that aligns on the top or also on the center of the left height column
General samples with tables:
http://pdfsharp.net/wiki/Invoice-sample.ashx
http://pdfsharp.net/wiki/HelloMigraDoc-sample.ashx

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