ststeiger / PdfSharpCore

Port of the PdfSharp library to .NET Core - largely removed GDI+ (only missing GetFontData - which can be replaced with freetype2)
Other
1.08k stars 237 forks source link

First example of PdfSharpCore doesn't work #377

Closed diegodrf closed 1 year ago

diegodrf commented 1 year ago

The first example of PdfSharpCore at index doesn't work when copy and paste.

// You’ll first need a PDF document:
PdfDocument document = new PdfDocument();

// And you need a page:
PdfPage page = document.AddPage();

// Drawing is done with an XGraphics object:
XGraphics gfx = XGraphics.FromPdfPage(page);

// Then you'll create a font:
XFont font = new XFont("Verdana", 20, XFontStyle.Bold);

// And you use that font to draw a string:
gfx.DrawString(
    "Hello, World!", font, XBrushes.Black,
    new XRect(0, 0, page.Width, page.Height),
    XStringFormat.Center);

// When drawing is done, write the file:
string filename = "HelloWorld.pdf";
document.Save(filename);

In the example XStringFormat calls Center, but it doesn't exist in the class.