2017-10-15 14 views
0

J'ai un pied de page qui va à droite et à gauche de chaque page. Chaque paragraphe du pied de page contient deux lignes de texte. Ce que je veux, c'est ajouter une ligne horizontale entre les 2 lignes de texte dans le pied de page.Migra Doc PDF Footer Styling

Voici le code pour ajouter le pied de page.

private void AddFooterData(Section section) { 
     // add prepared by. approved by etc 

     var rightFooterSection = new Paragraph { 
      Format = { Alignment = ParagraphAlignment.Right } 
     }; 
     rightFooterSection.AddText("Prepared By Eng: " + _preparedBy); 
     rightFooterSection.AddLineBreak(); 

     rightFooterSection.AddText("Page "); 
     rightFooterSection.AddPageField(); 
     rightFooterSection.AddText("/"); 
     rightFooterSection.AddNumPagesField(); 
     section.Footers.Primary.Add(rightFooterSection); 

     var date = DateTime.Now.ToString("yyyy/MM/dd"); 
     var leftSection = new Paragraph { 
      Format = { Alignment = ParagraphAlignment.Left } 
     }; 
     leftSection.AddText("Approved By: " + _approvedBy); 

     leftSection.AddLineBreak(); 
     leftSection.AddText(date); 
     section.Footers.Primary.Add(leftSection); 

    } 

Voici une image du résultat de pied de page souhaité.

enter image description here

Répondre

0

Je suis arrivé ce compris moi-même. Créer une table contenant 2 colonnes de même largeur que la page, Créez 2 lignes sur la ligne supérieure, définissez la bordure inférieure pour qu'elle soit visible. aligner le texte dans chaque ligne, donc la colonne de gauche serait alignée à gauche, la colonne de droite serait alignée à droite

private void AddFooterData(Section section) { 

     var rightFooterSection = new Paragraph { 
      Format = { Alignment = ParagraphAlignment.Right } 
     }; 
     rightFooterSection.AddText("Prepared By Eng: " + _preparedBy); 

     var rightFooterPagePar = new Paragraph { 
      Format = { Alignment = ParagraphAlignment.Right } 
     }; 
     rightFooterPagePar.AddText("Page "); 
     rightFooterPagePar.AddPageField(); 
     rightFooterPagePar.AddText("/"); 
     rightFooterPagePar.AddNumPagesField(); 


     var date = DateTime.Now.ToString("yyyy/MM/dd"); 
     var leftSection = new Paragraph { 
      Format = { Alignment = ParagraphAlignment.Left } 
     }; 
     var leftDateSection = new Paragraph { 
      Format = { Alignment = ParagraphAlignment.Left } 
     }; 
     leftSection.AddText("Approved By: " + _approvedBy); 
     leftDateSection.AddText(date); 
     var footerTable = section.Footers.Primary.AddTable(); 
     var col1 = footerTable.AddColumn(); 
     col1.Width = "5.5in"; 

     var col2 = footerTable.AddColumn(); 
     col2.Width = "5.5in"; 
     var row1 = footerTable.AddRow(); 
     row1[0].Add(leftSection); 
     row1[1].Add(rightFooterSection); 
     row1.Borders.Bottom.Visible = true; 
     row1.Borders.Bottom.Width = "0.10cm"; 
     var row2 = footerTable.AddRow(); 
     row2[0].Add(leftDateSection); 
     row2[1].Add(rightFooterPagePar);