Relorer / HTMLToQPDF

HTMLToQPDF is an extension for QuestPDF that allows to generate PDF from HTML
MIT License
80 stars 26 forks source link

Object reference not set to an instance of an object #11

Closed dong990411 closed 1 year ago

dong990411 commented 1 year ago

After I just added the package, I ran it directly and reported this error. No matter how you adjust it, it won't work,The code is as follows:

string html = @"<!DOCTYPE html>
                <html lang=""en"">
                <head>
                    <meta charset=""UTF-8"">
                    <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
                    <title>Document</title>
                </head>
                <body>
                    <h1>标题一</h1>
                    <img src=""https://file.ejiang.com:9001/childplat/resource/courseware/cover/9a2579ef-22af-4d9d-bd1a-5814df5107ca.jpg?size=m480"" />
                </body>
                </html>";
            Document.Create(container =>
            {
                container.Page(page =>
                {
                    page.Content().Column(col =>
                    {
                        col.Item().HTML(handler =>
                        {
                            handler.SetHtml(html);
                        });
                    });
                });
            }).GeneratePdf("123.pdf");
            Console.WriteLine("OK");