rdvojmoc / DinkToPdf

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

Converter returns empty byte array on ubuntu #162

Open b-nanovski opened 2 years ago

b-nanovski commented 2 years ago

Hi,

I am using DinkToPdf to convert a webpage into a PDF. I use the following code:

var converter = new SynchronizedConverter(new PdfTools());

            var doc = new HtmlToPdfDocument()
            {
                GlobalSettings =
                {
                    ColorMode = ColorMode.Color,
                    Orientation = Orientation.Portrait,
                    PaperSize = PaperKind.A4,
                    Margins = new MarginSettings() { Top = 10 },
                },
                Objects = {
                    new ObjectSettings()
                    {
                        Page = "https://en.wikipedia.org/wiki/Main_Page",
                    },
                }
            };

            try
            {
                byte[] pdf = converter.Convert(doc);
                FileResult fileResult = new FileContentResult(pdf, "application/pdf")
                {
                    FileDownloadName = "wikipedia_main_page.pdf"
                };

                return fileResult;
            }
            catch (Exception e)
            {
                return JsonConvert.SerializeObject(e);
            }

On Windows it works fine and returns a PDF properly. After I deploy to an ubuntu Apache server it also runs, but the Convert() method returns a byte[] that is empty. No error is thrown, no nothing.

I am using the proper native libraries - for Windows (the .dll file) and for Ubuntu (the .os or .dylib file - I don't know exactly which one it is, I copy all of them).

Any ideas why that would be?