C# 如何使用pdfsharp在pdf中绘制水平线
我们怎么能用pdfsharp画两条3厘米宽的水平线,中间有一个文本。我知道如何打印字符串,而且效果很好 我需要在两条横线之间打印日期。有人能帮我吗。 这是我打印日期的代码C# 如何使用pdfsharp在pdf中绘制水平线,c#,asp.net,C#,Asp.net,我们怎么能用pdfsharp画两条3厘米宽的水平线,中间有一个文本。我知道如何打印字符串,而且效果很好 我需要在两条横线之间打印日期。有人能帮我吗。 这是我打印日期的代码 graph.DrawString(date1, font, XBrushes.Black, new XRect(6.259843 * 72, 0.905512 * 72, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft); 您可
graph.DrawString(date1, font, XBrushes.Black, new XRect(6.259843 * 72, 0.905512 * 72,
pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft);
您可以使用此代码段。它将在页面中间画一条红线。您可能需要尝试使用
5
的行高来获得所需的大小
PdfPage pdfPage = yourPDFdoc.AddPage();
pdfPage.Width = XUnit.FromMillimeter(210);
pdfPage.Height = XUnit.FromMillimeter(297);
using (XGraphics gfx = XGraphics.FromPdfPage(pdfPage))
{
XPen lineRed = new XPen(XColors.Red, 5);
gfx.DrawLine(lineRed, 0, pdfPage.Height / 2, pdfPage.Width, pdfPage.Height / 2);
}