Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用pdfsharp在pdf中绘制水平线_C#_Asp.net - Fatal编程技术网

C# 如何使用pdfsharp在pdf中绘制水平线

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); 您可

我们怎么能用pdfsharp画两条3厘米宽的水平线,中间有一个文本。我知道如何打印字符串,而且效果很好

我需要在两条横线之间打印日期。有人能帮我吗。 这是我打印日期的代码

 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);
}