PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Jul 05, 2024 4:21 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed May 08, 2013 11:01 am 
Offline

Joined: Wed May 08, 2013 10:56 am
Posts: 17
Hey guys,

How can I increase the margin of my first page header only?

On my first page I have a company logo. If I set the Section.PageSetup.TopMargin it sets the margin for all pages. Here's my code for setting up the header:

Code:
var section = doc.AddSection();
      section.PageSetup.DifferentFirstPageHeaderFooter = true;

      var image = section.Headers.FirstPage.AddImage("logo.png");
      image.Width = "4cm";
      image.LockAspectRatio = true;
      image.RelativeVertical = RelativeVertical.Line;
      image.RelativeHorizontal = RelativeHorizontal.Margin;
      image.Top = ShapePosition.Top;
      image.Left = ShapePosition.Right;

      // doc content

      var heading = section.AddParagraph("This is a heading");


Top
 Profile  
Reply with quote  
PostPosted: Wed May 08, 2013 11:58 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!

As a workaround, I would add an empty paragraph to the first page (before the visible heading) and set its height to get that extra margin.
Or create a special style for the first heading on the first page and set SpaceBefore for this style.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed May 08, 2013 2:49 pm 
Offline

Joined: Wed May 08, 2013 10:56 am
Posts: 17
Hi Thomas,

I can't see an option for specifying the Height of a Paragraph.

Thanks,


Top
 Profile  
Reply with quote  
PostPosted: Wed May 08, 2013 3:01 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
To set the spacing with the first paragraph, try something like this:
Code:
paragraph.Format.SpaceBefore = "20mm";


Or if you add an empty dummy paragraph, try something like this:
Code:
paragraph.Format.LineSpacingRule = LineSpacingRule.Exactly;
paragraph.Format.LineSpacing = "20mm";

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed May 08, 2013 3:06 pm 
Offline

Joined: Wed May 08, 2013 10:56 am
Posts: 17
Thanks, that works great. Out of interest what is the standard Unit type for SpaceBefore/After?


Top
 Profile  
Reply with quote  
PostPosted: Wed May 08, 2013 3:26 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
The standard is points (1/72").

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 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