MigraDoc 格式化段落与 TextFrame 顶部对齐
MigraDoc Formatting Top Align Paragraph with TextFrame
对此很陌生...我似乎无法让 lower/left 上的段落与右侧旋转的 TextFrame 顶部对齐。在 MigraDoc 中有没有办法做到这一点? (注意:如果重要,红色文本会流到多个页面)
此外,我希望 TextFrame 显示在每个生成的页面上,但它没有。
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;
}
我想你只需要添加 myTextFrame.WrapFormat.Style = WrapStyle.Through;
对此很陌生...我似乎无法让 lower/left 上的段落与右侧旋转的 TextFrame 顶部对齐。在 MigraDoc 中有没有办法做到这一点? (注意:如果重要,红色文本会流到多个页面)
此外,我希望 TextFrame 显示在每个生成的页面上,但它没有。
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;
}
我想你只需要添加 myTextFrame.WrapFormat.Style = WrapStyle.Through;