PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jul 01, 2024 2:14 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jan 26, 2015 10:49 am 
Offline

Joined: Mon Jan 26, 2015 10:33 am
Posts: 2
Hello,
I'm creating an invoice with Migradoc and until this point I haven't had any greater problems I couldn't deal with. But now I'm trying to create something like a footer but still above the page numbers.
I want the text to always be at the bottom of the page but ,like I said still above the page numbers.
Is there a way to accomplish that ?

This is what I've got so far:
Code:
            #region ArtikelTabelle

            Paragraph lParagraph = lSection.AddParagraph();
            lParagraph.Format.FirstLineIndent = Unit.FromCentimeter(2.2);
            lParagraph.Format.SpaceBefore = Unit.FromCentimeter(2);
            lParagraph.AddText("Lieferschein");
            lParagraph.Format.Font.Size = 16;
            lParagraph.Format.Font.Bold = true;
            lParagraph.Format.SpaceAfter = 10;
            Table lTable = lSection.AddTable();

            lTable.Borders.Width = 0.75;
            lTable.Borders.Color = Color.Parse(ccGitterlinien); ;
            lTable.BottomPadding = 5;
            lTable.TopPadding = 5;
            lTable.Format.PageBreakBefore = true;

            Column lColumn = lTable.AddColumn(Unit.FromCentimeter(1));
            lColumn.Format.Alignment = ParagraphAlignment.Center;

            lTable.AddColumn(Unit.FromCentimeter(3));
            lColumn.Format.Alignment = ParagraphAlignment.Left;

            lTable.AddColumn(Unit.FromCentimeter(5));
            lColumn.Format.Alignment = ParagraphAlignment.Center;

            lTable.AddColumn(Unit.FromCentimeter(9));

            Row lRow = lTable.AddRow();
            lRow.VerticalAlignment = VerticalAlignment.Center;

            Cell lCell = lRow.Cells[0];
            lRow.Shading.Color = Colors.LightGray;
            lRow.HeadingFormat = true;
            lCell.AddParagraph("Pos.");
            lCell = lRow.Cells[1];
            lCell.AddParagraph("Menge");
            lCell = lRow.Cells[2];
            lCell.AddParagraph("ArtikelNr");
            lCell = lRow.Cells[3];
            lCell.AddParagraph("Beschreibung");

            var tabelle = new List<Artikel>();

            var lArtikel1 = new Artikel();

            lArtikel1.ArtikelNr = "123456";
            lArtikel1.Menge = 4;
            lArtikel1.MengenEinheit = "Stk.";
            lArtikel1.Beschreibung = "Hallo";

            var lArtikel2 = new Artikel();

            lArtikel2.ArtikelNr = "123456";
            lArtikel2.Menge = 4;
            lArtikel2.MengenEinheit = "Stk.";
            lArtikel2.Beschreibung = "Hallo";

            tabelle.Add(lArtikel1);
            tabelle.Add(lArtikel2);
            tabelle.Add(lArtikel2);
            tabelle.Add(lArtikel2);
            tabelle.Add(lArtikel2);
            tabelle.Add(lArtikel2);
            tabelle.Add(lArtikel2);
            tabelle.Add(lArtikel2);
            tabelle.Add(lArtikel2);
            tabelle.Add(lArtikel2);
            tabelle.Add(lArtikel2);
            tabelle.Add(lArtikel2);

            var lPosition = 1;
            foreach (var lArtikel in tabelle)
            {
               


                lRow = lTable.AddRow();
                lCell = lRow.Cells[0];
                lCell.AddParagraph(lPosition.ToString());
                lCell = lRow.Cells[1];
                lCell.AddParagraph(lArtikel.Menge + " " + lArtikel.MengenEinheit);
                lCell = lRow.Cells[2];
                lCell.AddParagraph(lArtikel.ArtikelNr);
                lCell = lRow.Cells[3];
                lCell.AddParagraph(lArtikel.Beschreibung);

                lPosition++;

            }




            #endregion

            TextFrame lFooterFrame = lSection.AddTextFrame();
            Paragraph lFooterParagraph =  lFooterFrame.AddParagraph();
            lFooterParagraph.Format.PageBreakBefore = true;
           
            lFooterFrame.Width = Unit.FromCentimeter(18);
            lFooterFrame.RelativeHorizontal = RelativeHorizontal.Character;
            lFooterFrame.RelativeVertical = RelativeVertical.Margin;
            lFooterParagraph.Format.Alignment = ParagraphAlignment.Left;
            lFooterFrame.Top = Unit.FromCentimeter(3);
            lFooterParagraph.AddText("Bemerkungen");
            lFooterParagraph.AddLineBreak();
            lFooterParagraph.AddText("Lorem ipsum dolor sit amet, " +
                                     "consetetur sadipscing elitr, sed diam " +
                                     "nonumy eirmod tempor invidunt ut labore et dolore " +
                                     "magna aliquyam erat, sed diam voluptua. At vero eos et accusam " +
                                     "et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata " +
                                     "sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur " +
                                     "sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna " +
                                     "aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et " +
                                     "ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor " +
                                     "sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy " +
                                     "eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. " +
                                     "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, " +
                                     "no sea takimata sanctus est Lorem ipsum dolor sit amet.");




            #region Seitenzahl

            lSection.PageSetup.OddAndEvenPagesHeaderFooter = true;
            lSection.PageSetup.StartingNumber = 1;

            HeaderFooter lHeader = lSection.Headers.Primary;
            lHeader.AddParagraph();

            lHeader = lSection.Headers.EvenPage;
            lHeader.AddParagraph();

            Paragraph lPageParagraph = new Paragraph();
            lPageParagraph.AddText("-");
            lPageParagraph.AddPageField();
            lPageParagraph.AddText("-");
            lPageParagraph.Format.Alignment = ParagraphAlignment.Center;


            lSection.Footers.Primary.Add(lPageParagraph);
            lSection.Footers.EvenPage.Add(lPageParagraph.Clone());

            #endregion
           





            PdfDocumentRenderer lRenderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);
            lRenderer.Document = xDocument;
            lRenderer.RenderDocument();


And like you see in the attached images the table works perfectly and so do the page numbers, but the text won't.
Attachment:
File comment: The text i want to write
text.PNG
text.PNG [ 46.03 KiB | Viewed 4395 times ]

Attachment:
File comment: the whole document
gesamt.png
gesamt.png [ 48.83 KiB | Viewed 4395 times ]


Thanks, in Advance :)


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 26, 2015 11:02 am 
Offline
PDFsharp Guru
User avatar

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

Just don't put your "Bemerkungen" into a TextFrame. You can use KeepTogether and KeepWithNext to avoid PageBreaks within this text (if that's what you want).
The "Bemerkungen" will appear only once below the table.

Or increase BottomMargin and FooterDistance in the PageSetup of your section to make room for the longer footer and add the "Bemerkungen" to the footer.
With version 1.50 beta you can have several paragraphs in the footer without TextFrames. In that case the "Bemerkungen" (remarks) will appear on every page.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 26, 2015 12:17 pm 
Offline

Joined: Mon Jan 26, 2015 10:33 am
Posts: 2
I wanted to keep them together and only once on the whole document and that's working now.
Thanks again. :D


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

All times are UTC


Who is online

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