DinkToPdf Converter returns empty byte array on ubuntu

322 Views Asked by At

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?

0

There are 0 best solutions below