PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Fri Nov 07, 2025 5:00 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Footer Formatting Issues
PostPosted: Tue Jul 16, 2013 2:14 pm 
Offline

Joined: Tue Jul 16, 2013 2:04 pm
Posts: 2
Hi, I am trying to duplicate a report that is generated in Word. I have got everything working correctly, except for the footer. I have the footer looking correctly, except it is exactly 1 cm too high. Here is the code I am running.
Code:
void CreatePage()
        {
            Section section = _document.AddSection();

            section.PageSetup.PageWidth = "21.59cm";
            section.PageSetup.PageHeight = "27.94cm";
            section.PageSetup.TopMargin = "3.81cm";
            section.PageSetup.LeftMargin = "2.54cm";
            section.PageSetup.RightMargin = "2.54cm";
            section.PageSetup.BottomMargin = "2.54cm";
            Image image = section.Headers.Primary.AddImage("../../line.png");
            image.Height = "0.2cm";
            image.Width = "16.51cm";
            image.RelativeVertical = RelativeVertical.Line;
            image.RelativeHorizontal = RelativeHorizontal.Page;
            image.Left = ShapePosition.Center;
            image.Top = ShapePosition.Top;
             
           
            // Put a logo in the header
            image = section.Headers.Primary.AddImage("../../Logo.png");
            image.Height = "1.524cm";
            image.Width = "2.032cm";
            image.WrapFormat.DistanceTop = "0.25cm";

            TextFrame frame = section.Headers.Primary.AddTextFrame();
            Paragraph framePara = frame.AddParagraph("Name");
            framePara.Format.Alignment = ParagraphAlignment.Center;
            framePara = frame.AddParagraph("PROJECT EXPERIENCE");
            framePara.Format.Alignment = ParagraphAlignment.Center;
            frame.Width = "21.59cm";
            frame.Left = "0cm";
            frame.Top = "2.05cm";
            frame.RelativeHorizontal = RelativeHorizontal.Page;
            frame.RelativeVertical = RelativeVertical.Page;
           
           
            image = section.Headers.Primary.AddImage("../../line.png");
            image.Height = "0.2cm";
            image.Width = "16.5cm";
           
            image.RelativeHorizontal = RelativeHorizontal.Page;
            image.Left = ShapePosition.Center;
            image.Top = ShapePosition.Top;
            image.WrapFormat.DistanceTop = "0.25cm";

            // Create footer
             Paragraph paragraph;

            frame = section.Footers.Primary.AddTextFrame();
            image = frame.AddImage("../../line.png");
            image.Height = "0.2cm";
            image.Width = "16.5cm";
            image.Left = ShapePosition.Center;
            image.Top = ShapePosition.Top;
            image.WrapFormat.DistanceBottom = "1cm";
            paragraph = frame.AddParagraph() ;
            paragraph.AddPageField();
            paragraph.Format.Font.Size = 11;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            frame.RelativeHorizontal = RelativeHorizontal.Page;
            frame.RelativeVertical = RelativeVertical.Line;

            frame.Left = ShapePosition.Center;

            //print projects
           
            paragraph = section.AddParagraph("Major Project Include:", "BodyStart");
            paragraph = section.AddParagraph("site","Site");
            for (int x = 0; x < 20; x++)
            {
                paragraph = section.AddParagraph("Project Name", "ProjectTitle");
                paragraph = section.AddParagraph("asdfg ioupwerj ;lkjasdfiopue kjweue a;kjep asdkjv nmdfgp eopit adkljb lawerpoi aasdkljer apoeiradfj aerpoia asdfl;kjwer opiasdf ", "Description");
            }
        }
    }


The rest of the code has been borrowed from the examples. I have been dealing with the footer for quite a while now, and I am starting to get frustrated. I have tried setting the exact location of the textframe, but nothing seems to get it down that extra 1 cm. Any pointers would be greatly appreciated.


Last edited by a.harper on Mon Jul 29, 2013 6:16 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 16, 2013 2:39 pm 
Offline

Joined: Tue Jul 16, 2013 2:04 pm
Posts: 2
I found a solution. It is hacky but it works. I added a margin of 1cm to the top of my textframe. It drove it down the 1cm I needed.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 117 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