HeaderFooter

HeaderFooter constructor

إنشاء رأس أو تذييل جديد من النوع المحدد.

public HeaderFooter(DocumentBase doc, HeaderFooterType headerFooterType)
معامليكتبوصف
docDocumentBaseوثيقة المالك.
headerFooterTypeHeaderFooterTypeأHeaderFooterType value الذي يحدد نوع الرأس أو التذييل.

ملاحظات

متىHeaderFooter تم إنشاؤه، فهو ينتمي إلى المستند المحدد، ولكنه ليس بعد جزءًا من المستند وParentNode يكونباطل.

لإلحاقHeaderFooterإلى أSection يستخدمInsertAfter ,InsertBefore أوHeadersFooters الممتلكات والأساليبAdd ,Insert.

أمثلة

يوضح كيفية إنشاء رأس وتذييل.

Document doc = new Document();

// قم بإنشاء رأس وألحق فقرة به. النص في تلك الفقرة
// سيظهر في أعلى كل صفحة من هذا القسم، فوق النص الأساسي.
HeaderFooter header = new HeaderFooter(doc, HeaderFooterType.HeaderPrimary);
doc.FirstSection.HeadersFooters.Add(header);

Paragraph para = header.AppendParagraph("My header.");

Assert.True(header.IsHeader);
Assert.True(para.IsEndOfHeaderFooter);

// قم بإنشاء تذييل وإلحاق فقرة به. النص في تلك الفقرة
// سيظهر في أسفل كل صفحة من هذا القسم، أسفل النص الرئيسي.
HeaderFooter footer = new HeaderFooter(doc, HeaderFooterType.FooterPrimary);
doc.FirstSection.HeadersFooters.Add(footer);

para = footer.AppendParagraph("My footer.");

Assert.False(footer.IsHeader);
Assert.True(para.IsEndOfHeaderFooter);

Assert.AreEqual(footer, para.ParentStory);
Assert.AreEqual(footer.ParentSection, para.ParentSection);
Assert.AreEqual(footer.ParentSection, header.ParentSection);

doc.Save(ArtifactsDir + "HeaderFooter.Create.docx");

أنظر أيضا