PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 21, 2019 10:02 pm

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
 Post subject: Tab positioning
PostPosted: Tue Apr 13, 2010 8:52 am 
Offline

Joined: Tue Apr 13, 2010 8:40 am
Posts: 2
Hello,

I had look at the invoice sample and tried to set a tabstop in my own migradoc document. Unfortunately I failed miserably.

What I tried to achieve:
Create a right aligned tab stop (that means any text written at this tab stop will expand left rather than right, doesn't it?) at a certain position.
In my case I tried to set the tab stop to the position of the right margin so that any text would neatly align to it.

// new style "MyStyle"
style = _document.Styles.AddStyle("MyStyle", "Normal");
style.ParagraphFormat.SpaceBefore = "3mm";
style.ParagraphFormat.SpaceAfter = "3mm";
style.ParagraphFormat.TabStops.Clear();
style.ParagraphFormat.TabStops.AddTabStop("19,8cm", TabAlignment.Right); // A
//style.ParagraphFormat.TabStops.AddTabStop(new Unit(19.8d, UnitType.Centimeter), TabAlignment.Right); // B

I think A and B should show pretty much the same result.. however they don't.
Also I wasn't able to achieve the "expand text to the left" thing.


Top
 Profile  
Reply with quote  
 Post subject: Re: Tab positioning
PostPosted: Tue Apr 13, 2010 9:12 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2952
Location: Cologne, Germany
I'd put the tabstop at 0.1 cm before the right margin (at least for a test).
venenum wrote:
I think A and B should show pretty much the same result.. however they don't.

If you don't write which results you got, I cannot comment on that.
Not sure whether "19.8cm" or "19,8cm" is correct here.

I'd use variant C:
Code:
Unit.FromCentimeter(19.8)

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: Tab positioning
PostPosted: Wed May 20, 2015 9:45 pm 
Offline

Joined: Wed Aug 27, 2014 8:06 am
Posts: 3
Hi Thomas,

I am having a similar problem understanding tabstops (unfortunately migradoc and pdfsharp have very poor documentation :( )

I have read few of your posts regrading tabstops.

So far I have gathered :

To have a text near to the left margin and another text near to the right margin, according to you , I should add left_text , add a tabstop (right aligned , with minimum width) and add right_text , Basically code should be something like :

// Adding footer to the document
var style = doc.Styles[StyleNames.Footer];
style.ParagraphFormat.TabStops.ClearAll();
// tabstop added : ("1 cm" , TabAlignment.Right)
style.ParagraphFormat.TabStops.AddTabStop(Unit.FromCentimeter(1), TabAlignment.Right , TabLeader.MiddleDot);
Paragraph footer_para = new Paragraph();
footer_para.AddText("left.");
footer_para.AddTab();
footer_para.AddText("right.");
footer_para.Format.Borders.Visible = true;
sec.Footers.Primary.Add(footer_para);

After doing this I get the output (I am using version 1.32) like :
|left.right.|

"|" indicates page margin.

NO TABSTOP ADDED.

I also have attached my code , pdf output , and mdddl file (all are in the zip file)

1. Please help me understand this output.
2. Please give me an explanation of how tabstops work (what is the meaning of TabAlignment, what happens if I add multiple tabstops with different alignment and units , etc). Hopefully update the documentation :P.
3. How to get the desired output as below :
|Left.·····················································································································································Right.|

Thank You


Attachments:
File comment: Tabstop Problem.zip contains the program.cs , test.pdf and test.mdddl
Tabstop Problem.zip [10.34 KiB]
Downloaded 104 times
Top
 Profile  
Reply with quote  
 Post subject: Re: Tab positioning
PostPosted: Thu May 21, 2015 7:39 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2952
Location: Cologne, Germany
souravsaraf1230 wrote:
To have a text near to the left margin and another text near to the right margin, according to you , I should add left_text , add a tabstop (right aligned , with minimum width) and add right_text
No!!!
Suppose you have DIN A4 with 2.5 cm margins left and right, then the tab stop will have to be at 16 cm (or maybe 15.8 cm). You set it to 1 cm - this tab stop will be used only if left-aligned text plus right-aligned text will fit into 1 cm.

Tab stops work much like those in Microsoft Word, so you can play around with tab stops in Word (you can easily test different setups).

_________________
Regards
Thomas Hoevel
PDFsharp Team


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: Baidu [Spider], Google [Bot] and 5 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