首页 文章

MigraDoc格式顶部与TextFrame对齐段落

提问于
浏览
0

对此非常陌生......我似乎无法将低位/左对顶的段落与右侧的旋转TextFrame对齐 . 有没有办法在MigraDoc中做到这一点? (注意:如果重要,红色文本会流到多个页面)

另外,我希望TextFrame显示在每个生成的页面上,但事实并非如此 .

enter image description here

enter image description here

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;

        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 myTextFrame = section.AddTextFrame();
        myTextFrame.Orientation = TextOrientation.Downward;
        //moves text to the right
        myTextFrame.Left = 550;
        myTextFrame.Width = 10;
        myTextFrame.Top = 0;
        myTextFrame.Height = 150;

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


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

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

        return document;
    }

1 回答

  • 1

    我想你要添加的是 myTextFrame.WrapFormat.Style = WrapStyle.Through;

相关问题