【发布时间】:2019-08-08 19:38:14
【问题描述】:
我正在寻找使用 Xamarin(Xamarin Forms 或 Xamarin iOS)从字符串生成 pdf 文件的解决方案。
我找到了 iTextSharp、SelectPDF 或 Syncfusion 等库,但所有这些库都必须付费。我需要完全免费的解决方案。
PDFsharp 库几乎可以工作:
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);
gfx.DrawString("Hello, World!", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.Center);
const string filename = "HelloWorld.pdf";
document.Save(filename);
但在 'XFont' 处出现错误:“对类型 'FontFamily' 的引用声称它是在 'System.Drawing' 中定义的,但找不到它”。
Apple 提供了解决方案:link ,但这是我不熟悉的 Objective-c,当我将此代码粘贴到 Visual Studio 中时出现很多错误。
你有用 C# 编写的解决方案吗?
【问题讨论】:
标签: xamarin xamarin.forms pdf-generation