Skip to content

Method not found: PdfSharp.Drawing.XGraphics PdfSharp.Drawing.XGraphics.CreateMeasureContext(PdfSharp.Drawing.XSize, PdfSharp.Drawing.XGraphicsUnit, PdfSharp.Drawing.XPageDirection) #206

@dnsnx

Description

@dnsnx

I have a fresh project Console App, .NET 8. I have installed PDFSharp 6.2.0-preview-1 and HtmlRenderer.PdfSharp (1.5.1-beta-1) and HtmlRenderer.Core (1.5.1-beta-1).
My code is very simple from the readme.txt:

PdfDocument pdf = PdfGenerator.GeneratePdf("<p><h1>Hello World</h1>This is html rendered text</p>", PageSize.A4);
pdf.Save("C:\\Users\\username\\Downloads\\document.pdf");

When I debug the project, I get this exception:

System.MissingMethodException: 'Method not found: 'PdfSharp.Drawing.XGraphics PdfSharp.Drawing.XGraphics.CreateMeasureContext(PdfSharp.Drawing.XSize, PdfSharp.Drawing.XGraphicsUnit, PdfSharp.Drawing.XPageDirection)'.'

Here are some details:

Source: "HtmlRenderer.PdfSharp"
StackTrace:

at TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.AddPdfPages(PdfDocument document, String html, PdfGenerateConfig config, CssData cssData, EventHandler1 stylesheetLoad, EventHandler1 imageLoad)
at TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(String html, PdfGenerateConfig config, CssData cssData, EventHandler1 stylesheetLoad, EventHandler1 imageLoad)
at TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(String html, PageSize pageSize, Int32 margin, CssData cssData, EventHandler1 stylesheetLoad, EventHandler1 imageLoad)
at Program.

$(String[] args) in C:\Company\Projects\C_Sharp\Test\GeneratePdf\GeneratePdf\Program.cs:line 12

I've created a new project with .NET Framework 4.7.2 and installed HtmlRenderer.PdfSharp (1.5.1-beta-1) and HtmlRenderer.Core (1.5.1-beta-1). Here the code works fine without error. Is it an issue with .NET?

Any help appriciated. Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions