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

Can't convert Page url to Pdf on Linux #180

Open Bartosz97 opened 1 year ago

Bartosz97 commented 1 year ago

I've corrected the configuration of Dockerfile and it's working correctly on Linux (don't have a problem with dependencies). But when I want to use the Convert method from DinkToPdf, it always returns an empty byte[] on Linux. (on Windows there return some bytes). A similar problem was described here: https://stackoverflow.com/questions/72901484/dinktopdf-converter-returns-empty-byte-array-on-ubuntu

If I am using ObjectSettings.Page = url from the page, there is this problem. Otherwise, if I am using ObjectSettings.HtmlContent = some content(string), then will generate correctly. This is only on Linux behavior. On Windows, both settings work properly.

My code: var document = new HtmlToPdfDocument { GlobalSettings = { ColorMode = ColorMode.Color, Orientation = model.IsLandscape ? Orientation.Landscape : Orientation.Portrait, PaperSize = PaperKind.A4Plus, Margins = new MarginSettings { Bottom = MarginTopBottom, Left = MarginLeftRight, Right = MarginLeftRight, Top = MarginTopBottom, Unit = Unit.Millimeters } }, Objects = { new ObjectSettings { PagesCount = true, WebSettings = { DefaultEncoding = "utf-8" } Page = model.HtmlUrl } } };

Some logs during invoke Convert method: QSslSocket: cannot resolve CRYPTO_num_locks QSslSocket: cannot resolve CRYPTO_set_id_callback QSslSocket: cannot resolve CRYPTO_set_locking_callback QSslSocket: cannot resolve sk_free QSslSocket: cannot resolve sk_num QSslSocket: cannot resolve sk_pop_free QSslSocket: cannot resolve sk_value QSslSocket: cannot resolve SSL_library_init QSslSocket: cannot resolve SSL_load_error_strings QSslSocket: cannot resolve SSLv3_client_method QSslSocket: cannot resolve SSLv23_client_method QSslSocket: cannot resolve SSLv3_server_method QSslSocket: cannot resolve SSLv23_server_method QSslSocket: cannot resolve X509_STORE_CTX_get_chain QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf

Does somebody have the same problem only on Linux and for urlPage?

Thanks a lot!

Psyk0loge commented 1 year ago

Yeah actually I think we are facing the same issue right now. Using Convert works on Windows but returns empty bytes on Linux

Bartosz97 commented 1 year ago

ok, I've used this package and it's working correctly on linux machine: https://github.com/HakanL/WkHtmlToPdf-DotNet