PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Dec 01, 2020 12:13 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Tue Aug 21, 2012 9:53 am 
Offline

Joined: Mon Aug 20, 2012 12:21 pm
Posts: 3
A question from a newbie:

How do I set margins and padding for a Paragraph?
As I can see the class itself does not provide methods for it.

Any hint is appreciated, thank you!


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 21, 2012 12:37 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3047
Location: Cologne, Germany
Hi!
Basille wrote:
How do I set margins and padding for a Paragraph?
Try paragraph.Format and look for LeftIndent, RightIndent, FirstLineIndent, SpaceBefore, and SpaceAfter.

You can create a Style with your settings and just assign the style to the paragraph.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 21, 2012 2:25 pm 
Offline

Joined: Mon Aug 20, 2012 12:21 pm
Posts: 3
Hi Thomas and thanks for the response.
Is it possible to style a specific paragraph? So far I only saw the means to address all paragraphs.


Top
 Profile  
Reply with quote  
PostPosted: Tue Aug 21, 2012 2:53 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3047
Location: Cologne, Germany
Hi!
Basille wrote:
Is it possible to style a specific paragraph?
Yes, check this sample:
http://www.pdfsharp.net/wiki/HelloMigra ... Redirect=1

Look at DefineCover and DefineTableOfContents.

There's no way to change all paragraphs in a document. You can only change all paragraphs that use the same style by changing that style.
You can add styles when you need more styles.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 22, 2012 5:31 am 
Offline

Joined: Mon Aug 20, 2012 12:21 pm
Posts: 3
OK, I will try that. Thank you!


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 24, 2020 10:54 am 
Offline

Joined: Tue Feb 18, 2020 7:40 pm
Posts: 11
Ok, I scrapped together a page. This is computer generated with numerous different types of results, here are just a few. Until now I was using pdfsharp successfully. Now I wanted to switch to migradoc to reduce my code.

The bits on the picture marked yellow are paragraphs. Now for the second yellow paragraph I have set the option .keeptogether, and on the table before I set .stickwithnext.
But would prefer to leave out the .stickwithnext on the table, and have an option one the paragraph, .leaveOutIfFirst. All objects could have that.

I have a couple of other problems if anyone can help.
I have a big problem calculating width of the empty cells left and right of the table.
Here is my calculation:

left_right_cell_width = (myDoc.DefaultPageSetup.PageWidth.Point - mySect.PageSetup.LeftMargin.Point - mySect.PageSetup.RightMargin.Point + myDoc.Styles("Normal").ParagraphFormat.Borders.DistanceFromLeft.Point + myDoc.Styles("Normal").ParagraphFormat.Borders.DistanceFromRight.Point - myDoc.Styles("Normal").ParagraphFormat.LeftIndent.Point + 0.28 - tableWidth) / 2

Now what am I doing wrong? As you see I had to add 0.28 points so that it works correct?


Attachments:
migradoc example.PNG
migradoc example.PNG [ 91.59 KiB | Viewed 5539 times ]
Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 27, 2020 10:35 am 
Offline

Joined: Tue Feb 18, 2020 7:40 pm
Posts: 11
(myDoc.DefaultPageSetup.PageWidth.Point - mySect.PageSetup.LeftMargin.Point - mySect.PageSetup.RightMargin.Point + myDoc.Styles("Normal").ParagraphFormat.Borders.DistanceFromLeft.Point + myDoc.Styles("Normal").ParagraphFormat.Borders.DistanceFromRight.Point - myDoc.Styles("Normal").ParagraphFormat.LeftIndent.Point )

Is the above formula correct? Because I get an error about 0.28 points when I try to align it with my table. I posted an example in another threat, but wanted to make it clearer.


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 27, 2020 2:33 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3047
Location: Cologne, Germany
iluvathar wrote:
Because I get an error about 0.28 points when I try to align it with my table.
Error?
By default text in tables aligns with text outside tables. To achieve that, tables are by default indented a little bit to the left.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Fri Feb 28, 2020 9:51 am 
Offline

Joined: Tue Feb 18, 2020 7:40 pm
Posts: 11
I get this, but how do I align paragraph lines with table lines. In the example I had to add 0.28 points to calculation.
So I can get the width of empty table cells on left right. However tables are dynamically generated, therefore they can have wider column and more column. I am worried that my line will in some cases skip one point and not be align to paragraph border. So is my 0.28 point correct?

I hope this makes sense.

Quote:
To achieve that, tables are by default indented a little bit to the left.


So I should use that in my calculation also?

I made the formula mentioned before and I want to change it so it is correct, can you/anyone help? I have my primary table width, now I have to calculate left and right column, so I get the lines aligned.


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

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Google [Bot] and 22 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