在Xamarin.ios中使用PDFsharp

在Xamarin.ios中使用PDFsharp,ios,xamarin.ios,pdfsharp,Ios,Xamarin.ios,Pdfsharp,在Xamarin.ios中使用PDFsharp和MigraDoc时,我遇到了一个问题。原因是System.Drawing在Xamarin.ios中不可用。实际上,我不确定如何编辑PDFsharp中的示例代码以使用Ios。希望有人能帮忙 这是从PDFsharp网站使用的示例代码,在gfx处出现错误。DrawString: static void CreatePdf() { // Create a new PDF document PdfDocument do

Xamarin.ios
中使用PDFsharp和MigraDoc时,我遇到了一个问题。原因是
System.Drawing
Xamarin.ios
中不可用。实际上,我不确定如何编辑PDFsharp中的示例代码以使用Ios。希望有人能帮忙

这是从PDFsharp网站使用的示例代码,在
gfx处出现错误。DrawString

static void CreatePdf()
    {
        // Create a new PDF document
        PdfDocument document = new PdfDocument();
        document.Info.Title = "Created with PDFsharp";

        // Create an empty page
        PdfPage page = document.AddPage();

        // Get an XGraphics object for drawing
        XGraphics gfx = XGraphics.FromPdfPage(page);

        // Create a font
        XFont font = new XFont("Verdana", 20, XFontStyle.BoldItalic);

        // Draw the text !ERROR IS HERE!
        gfx.DrawString("Hello, World!", font, XBrushes.Black,
          new XRect(0, 0, page.Width, page.Height),
          XStringFormats.Center);

        // Save the document...
        const string filename = "HelloWorld.pdf";
        document.Save(filename);
        // ...and start a viewer.
        Process.Start(filename);
    }

gfx。DrawString
是来自PDFsharp的一种方法。您收到了哪条错误消息?您是否为PDFsharp添加了
using
语句?@Viveladéraisson是的,我已添加了所有using语句。但是,我还没有实际运行代码,因为我在这部分代码下面有红线。当我右键单击它时,它表示我需要添加对System.Drawing的引用。但是,这在参考资料中的Xamarin.ios.Add System、System.core、System.xml中不可用。还添加了“使用PdfSharp.Drawing;使用PdfSharp.Pdf;”这应该可以解决您的问题。@Darshana我已经尝试添加所有名称空间,但仍然没有成功。我已经在我的主要问题后附加了一个屏幕截图,它显示了我得到的错误和VisualStudio给我的解决方案