PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Mar 19, 2024 4:58 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Nov 27, 2021 6:47 pm 
Offline

Joined: Sat Nov 27, 2021 6:25 pm
Posts: 2
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?


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 29, 2021 8:20 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 905
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 29, 2021 10:33 pm 
Offline

Joined: Sat Nov 27, 2021 6:25 pm
Posts: 2
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


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 29, 2021 10:36 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 905
Location: CCAA
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

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 35 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group