【发布时间】:2018-06-28 07:16:40
【问题描述】:
我使用 pdfSharp 将文本插入 PDF 文件,但是当我使用字体 Times New Roman 粗体时,出现了一些问题。
这是我的代码:
using PdfSharp.Pdf;
using PdfSharp.Drawing;
PdfSharp.Pdf.PdfDocument pdf = new PdfSharp.Pdf.PdfDocument();
pdf.Info.Title = filePrint;
PdfSharp.Pdf.PdfPage pdfPage = pdf.AddPage();
pdfPage.Size = PdfSharp.PageSize.A4;
using (XGraphics graph = XGraphics.FromPdfPage(pdfPage))
{
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
XFont fontBold = new XFont("Times New Roman", 10, XFontStyle.Bold, options);
graph.DrawString("Đây là đoạn text bold", fontBold, XBrushes.Black, new XRect(75.6, 56, 30, 30), XStringFormats.TopLeft);
}
那么我的结果是这样的:
请帮助我找到解决此错误的方法。
【问题讨论】: