I am trying to use PdfSharpCore and MigraDocCore to create a pdf file in .net maui with vs pre 2022
this is my code
using System;
using System.Diagnostics;
using System.Windows.Input;
using MigraDocCore.DocumentObjectModel;
using MigraDocCore.Rendering;
using PdfKit;
using PdfSharpCore;
using PdfSharpCore.Drawing;
using PdfSharpCore.Pdf;
private void CreatePdf()
{ System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
PdfSharpCore.Pdf.PdfDocument document = new PdfSharpCore.Pdf.PdfDocument();
PdfSharpCore.Pdf.PdfPage page = document.AddPage();
PdfSharpCore.Drawing.XGraphics gfx = XGraphics.FromPdfPage(page);
gfx.MUH = PdfFontEncoding.Unicode;
var ren = new PdfDocumentRenderer(true);
XFont font = new XFont("OpenSans-Semibold", 20, XFontStyle.Bold);
gfx.DrawString("Hello, World!", font, XBrushes.Black, new XRect(0, 0, page.Width, page.Height));
}
but I have an error with XFont
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
you need create the file FileFontResolver.
And Then, i call this file in app.xaml.cs