Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
dnsnx opened this issue Oct 2, 2024 · 1 comment

Comments

@dnsnx
Copy link

dnsnx commented Oct 2, 2024

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.

@FR33M0N7
Copy link

I resolved this by removing the original library and letting this extension install it as it should.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants