Migradoc 标题和内容重叠

时间:2021-06-16 14:01:40

标签: c# pdfsharp migradoc

我正在处理使用 migradoc 生成的 pdf。然而,当标题中的一行由于大于 3 或 4 行的地址而扩展时,标题和主要部分会重叠。

我已经使用了 MigraDoc table goes over header on page 2? 上的答案,但上边距根本不会移动。

我哪里出错了?

Section section = doc.AddSection();
section.PageSetup.TopMargin = Unit.FromCentimeter(4);

MigraDoc.DocumentObjectModel.Tables.Table quoteTable = section.Headers.Primary.AddTable();
quoteTable.Style = "Table";
quoteTable.Borders.Color = Colors.Black;
quoteTable.Borders.Width = 0.25;
quoteTable.Borders.Left.Width = 0.5;
quoteTable.Borders.Right.Width = 0.5;
quoteTable.Rows.LeftIndent = 0;
quoteTable.TopPadding = 3;
quoteTable.BottomPadding = 3;

quoteRow = quoteTable.AddRow();
quoteRow.HeadingFormat = true;
quoteRow.Format.Alignment = ParagraphAlignment.Center;
quoteRow.Format.Font.Bold = true;
quoteRow.Shading.Color = Colors.White;
quoteRow.Cells[0].AddParagraph("Customer Name");
quoteRow.Cells[0].MergeDown = 2;
quoteRow.Cells[0].Format.Alignment = ParagraphAlignment.Left;
quoteRow.Cells[0].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Top;
quoteRow.Cells[0].Format.Font.Bold = true;
quoteRow.Cells[0].Shading.Color = headingColour;
quoteRow.Cells[1].AddParagraph(contactName + Environment.NewLine + completeAddressDetails);
quoteRow.Cells[1].MergeDown = 2;
quoteRow.Cells[1].Format.Alignment = ParagraphAlignment.Left;
quoteRow.Cells[1].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Top;

MigraDoc.DocumentObjectModel.Tables.Table prodTable = section.AddTable();
prodTable.Style = "Table";
prodTable.Borders.Color = Colors.Black;
prodTable.Borders.Width = 0.25;
prodTable.Borders.Left.Width = 0.5;
prodTable.Borders.Right.Width = 0.5;

MigraDoc.DocumentObjectModel.Tables.Row row = prodTable.AddRow();
row.Format.Alignment = ParagraphAlignment.Center;
row.Format.Font.Bold = true;
row.Shading.Color = Colors.LightGray;
row.BottomPadding = 3;
row.TopPadding = 3;
row.Cells[0].AddParagraph("Manufacturer Product Code");
row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
row.Cells[0].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Bottom;
row.Cells[1].AddParagraph("Product Description");
row.Cells[1].Format.Alignment = ParagraphAlignment.Left;
row.Cells[1].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Bottom;
row.Cells[2].AddParagraph("Qty" + Environment.NewLine + " Required");
row.Cells[2].Format.Alignment = ParagraphAlignment.Right;
row.Cells[2].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Bottom;

0 个答案:

没有答案