rdvojmoc / DinkToPdf

C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.
MIT License
1.09k stars 416 forks source link

Qt: Could not initialize OLE (error 80010106) #153

Closed danijel88 closed 2 years ago

danijel88 commented 2 years ago

Hello, I want to use lib in .net core mvc application. Using .net5

As DI configuration I had did : services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));

And code for generating PDF is

  var globalSettings = new GlobalSettings
            {
                ColorMode = ColorMode.Color,
                Orientation = Orientation.Portrait,
                PaperSize = PaperKind.A4,
                Margins = new MarginSettings { Top = 10 },
                DocumentTitle = "PDF Report",
            };
            var objectSettings = new ObjectSettings
            {
                PagesCount = true,
                HtmlContent = sb.ToString(),
                WebSettings = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "assets", "styles.css") },
                HeaderSettings = { FontName = "Arial", FontSize = 9, Right = "Page [page] of [toPage]", Line = true },
                FooterSettings = { FontName = "Arial", FontSize = 9, Line = true, Center = "Report Footer" }
            };
            var pdf = new HtmlToPdfDocument()
            {
                GlobalSettings = globalSettings,
                Objects = { objectSettings }
            };
            var file = _converter.Convert(pdf);

            return File(file, "application/pdf");

But when I call method for generating PDF in console is written: Qt: Could not initialize OLE (error 80010106)

May I ask what I did wrong ? Regards,