Skip to content

Commit

Permalink
Updated examples
Browse files Browse the repository at this point in the history
  • Loading branch information
falleretic committed Nov 23, 2023
1 parent 7dc6a64 commit d56734e
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ public void CreateHeaderFooter()
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Use HeaderPrimary and FooterPrimary
// if you want to set header/footer for all document.
// This header/footer type also responsible for odd pages.
//ExStart:HeaderFooterType
//GistId:84cab3a22008f041ee6c1e959da09949
builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
builder.Write("Header for the first page.");
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.Write("Header for page.");
//ExEnd:HeaderFooterType

builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.Write("Header for odd page.");
builder.Write("Footer for page.");

doc.Save(ArtifactsDir + "WorkingWithHeadersAndFooters.CreateHeaderFooter.docx");
//ExEnd:CreateHeaderFooter
Expand All @@ -40,6 +43,8 @@ public void DifferentFirstPage()

builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
builder.Write("Header for the first page.");
builder.MoveToHeaderFooter(HeaderFooterType.FooterFirst);
builder.Write("Footer for the first page.");

builder.MoveToSection(0);
builder.Writeln("Page 1");
Expand All @@ -64,7 +69,11 @@ public void OddEvenPages()
builder.MoveToHeaderFooter(HeaderFooterType.HeaderEven);
builder.Write("Header for even pages.");
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.Write("Header for odd pages.");
builder.Write("Header for odd pages.");
builder.MoveToHeaderFooter(HeaderFooterType.FooterEven);
builder.Write("Footer for even pages.");
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
builder.Write("Footer for odd pages.");

builder.MoveToSection(0);
builder.Writeln("Page 1");
Expand Down Expand Up @@ -104,9 +113,9 @@ public void FontProps()
builder.Font.Name = "Arial";
builder.Font.Bold = true;
builder.Font.Size = 14;
builder.Write("Header for odd page.");
builder.Write("Header for page.");

doc.Save(ArtifactsDir + "WorkingWithHeadersAndFooters.HeaderFooterFontProps.docx");
doc.Save(ArtifactsDir + "WorkingWithHeadersAndFooters.FontProps.docx");
//ExEnd:FontProps
}

Expand Down Expand Up @@ -164,7 +173,6 @@ public void LinkToPreviousHeaderFooter()

builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

builder.Font.Name = "Arial";
builder.Font.Size = 12;
builder.Write("New Header for the first page.");
Expand All @@ -191,7 +199,10 @@ public void SectionsWithDifferentHeaders()
builder.Font.Bold = true;
builder.Font.Size = 14;
builder.Write("Header for the first page.");


builder.MoveToDocumentEnd();
builder.InsertBreak(BreakType.SectionBreakNewPage);

builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
// Insert a positioned image into the top/left corner of the header.
// Distance from the top/left edges of the page is set to 10 points.
Expand Down

0 comments on commit d56734e

Please sign in to comment.