我正在使用 PDFSharp 在 C# 中創建一個 PDF,我想在兩個文本塊之間添加黑色下劃線,如下所示:

這是我用來撰寫 PDF 的代碼的(部分):
PdfDocument pdf = new PdfDocument();
PdfPage page = pdf.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont title = new XFont("Times New Roman", 30, XFontStyle.Bold);
XFont formatBody = new XFont("Times New Roman", 15);
XImage image = XImage.FromFile("Logo.png");
gfx.DrawString("Text Title", title, XBrushes.Black,
new XRect(0, 75, page.Width, page.Height), XStringFormats.TopCenter);
//LINE SEPARATOR HERE
gfx.DrawString("Body text", formatBody, XBrushes.Black,
new XRect(50, 130, page.Width, page.Height), XStringFormats.TopLeft);
在此先感謝您的幫助。
uj5u.com熱心網友回復:
畫一條線很簡單:
gfx.DrawLine(XPens.DarkGreen, 0, 120, page.Width, 0);
PDFsharp 示例解釋如下:http ://pdfsharp.net/wiki/Graphics-sample.ashx#Draw_simple_lines_0
示例源代碼可以在這里找到:https :
//github.com/empira/PDFsharp-samples
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/351197.html
