MigraDoc - 将 TextFrame 置于动态生成 Pages/Sections

MigraDoc - Put TextFrame on Dynamically Generated Pages/Sections

红色段落生成多页。是否可以将 TextFrame(不在页眉或页脚中)显示在 MigraDoc 中每个动态生成的 page/section 上,而不将其放在页眉或页脚中?

public static Document CreateWorkOrderPDF2(Document document, string filename, string WorkOrderHeader, string myMessage)
    {
        Section section = document.AddSection();
        section.PageSetup.PageFormat = PageFormat.Letter;

        section.PageSetup.StartingNumber = 1;

        section.PageSetup.LeftMargin = 40;
        //Sets the height of the top margin
        section.PageSetup.TopMargin = 100;
        section.PageSetup.RightMargin = 40;
        section.PageSetup.BottomMargin = 40;

        //HeaderFooter
        HeaderFooter header = section.Headers.Primary;
        header.Format.Font.Size = 16;
        header.Format.Font.Color = Colors.DarkBlue;

        //Image
        MigraDoc.DocumentObjectModel.Shapes.Image headerImage = header.AddImage("../../Fonts/castorgate.regular.png");
        headerImage.Width = "2cm";

        Paragraph headerParagraph = header.AddParagraph(WorkOrderHeader);
        headerParagraph.Format.Font.Name = "Consolas";

         //Vertical Text
        TextFrame WorkOrderVerticalTextFrame = section.AddTextFrame();
        WorkOrderVerticalTextFrame.Orientation = TextOrientation.Downward;
        //moves text to the right
        WorkOrderVerticalTextFrame.Left = 550;
        WorkOrderVerticalTextFrame.Width = 10;
        WorkOrderVerticalTextFrame.Top = 0;
        WorkOrderVerticalTextFrame.Height = 150;
        WorkOrderVerticalTextFrame.WrapFormat.Style = WrapStyle.Through;

        Paragraph WorkOrderVerticalParagraph = WorkOrderVerticalTextFrame.AddParagraph();
        WorkOrderVerticalParagraph.Format.Alignment = ParagraphAlignment.Left;
        WorkOrderVerticalParagraph.Format.Font.Name = "Consolas";
        WorkOrderVerticalParagraph.Format.Font.Size = 8;
        WorkOrderVerticalParagraph.AddText(WorkOrderHeader);
        //WorkOrderVerticalParagraph.Format.Borders.Width = .5;


        //BODY PARAGRAPH
        Paragraph EstRecordsParagraph = section.AddParagraph(myMessage);
        EstRecordsParagraph.Format.Font.Size = 10;
        EstRecordsParagraph.Format.Font.Color = Colors.DarkRed;
        EstRecordsParagraph.Format.Borders.Width = .5;
        EstRecordsParagraph.Format.RightIndent = 0;

        Paragraph renderDate = section.AddParagraph();
        renderDate = section.AddParagraph("Work Order Generated: ");
        renderDate.AddDateField();

        return document;
    }

没有

您可以向该部分添加一个TextFrame;然后它将在该部分出现一次。

您可以将 TextFrame 添加到页眉或页脚;然后它将出现在页眉或页脚出现的每个页面上。您可以对文本框使用绝对位置,使它们位于页面上 header/footer 区域之外的任何位置。