PDFsharp 如何在文档中添加复选框
PDFsharp how to add checkboxes to document
我一直在寻找将复选框添加到 PDFsharp 文档的最佳方法。
到目前为止,我只能使用 Wingdings 字体添加字符串 "\u00fd"
。仅当使用 Acrobat Reader 打开 PDF 文档时它才有效。但是如果 Chrome 或 IE 打开它,而不是一个复选框,它会显示一个不可读的字符。
关于 PDFsharp 的任何想法或更好的替代品(免费或开源)?
我对PDF文件的要求很简单,一两份报告就可以了。
按照 PDFsharp 新手提供的链接嵌入字体。
绘制复选框:
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode,
PdfFontEmbedding.Always);
XFont prevCheckboxFont = new XFont("WingDings", 12, XFontStyle.Regular, options);
XRect prevCheckboxPos = new XRect(XUnit.FromInch(3.20), XUnit.FromInch(3.30),
XUnit.FromInch(1.25), XUnit.FromInch(.10));
string prevCheckboxText = "\u00FE";
gfx.DrawString(prevCheckboxText, prevCheckboxFont, XBrushes.Black,
prevCheckboxPos, XStringFormats.TopLeft);
我们使用 Wingdings 在 PDF 中创建复选框,它们适用于 Adobe Reader、Firefox 和 Chrome。
确保在 PDF 文件中嵌入字体。
对于旧版本 1.32 及更早版本,您必须指定一个标志才能嵌入字体:
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode,
PdfFontEmbedding.Always);
XFont font = new XFont("Times New Roman", 12, XFontStyle.Regular, options);
在当前版本(1.50 及更高版本)中,始终嵌入字体并删除该选项。
我一直在寻找将复选框添加到 PDFsharp 文档的最佳方法。
到目前为止,我只能使用 Wingdings 字体添加字符串 "\u00fd"
。仅当使用 Acrobat Reader 打开 PDF 文档时它才有效。但是如果 Chrome 或 IE 打开它,而不是一个复选框,它会显示一个不可读的字符。
关于 PDFsharp 的任何想法或更好的替代品(免费或开源)?
我对PDF文件的要求很简单,一两份报告就可以了。
按照 PDFsharp 新手提供的链接嵌入字体。
绘制复选框:
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode,
PdfFontEmbedding.Always);
XFont prevCheckboxFont = new XFont("WingDings", 12, XFontStyle.Regular, options);
XRect prevCheckboxPos = new XRect(XUnit.FromInch(3.20), XUnit.FromInch(3.30),
XUnit.FromInch(1.25), XUnit.FromInch(.10));
string prevCheckboxText = "\u00FE";
gfx.DrawString(prevCheckboxText, prevCheckboxFont, XBrushes.Black,
prevCheckboxPos, XStringFormats.TopLeft);
我们使用 Wingdings 在 PDF 中创建复选框,它们适用于 Adobe Reader、Firefox 和 Chrome。
确保在 PDF 文件中嵌入字体。
对于旧版本 1.32 及更早版本,您必须指定一个标志才能嵌入字体:
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode,
PdfFontEmbedding.Always);
XFont font = new XFont("Times New Roman", 12, XFontStyle.Regular, options);
在当前版本(1.50 及更高版本)中,始终嵌入字体并删除该选项。