fpanaccia / Wkhtmltopdf.NetCore-deprecated

Rotativa + Net Core
The Unlicense
220 stars 94 forks source link

Not render images and css in docker container with asp.net core 3.1 #20

Closed krlosmederos closed 4 years ago

krlosmederos commented 4 years ago

I get images and css by urls in the html, I use method GetByteArrayViewInHtml, when I run my application in localhost (windows) all is fine, but when I execute from container only show text in pdf without style and without images. My dockerfile copy the binaries and I give permisions chmod 755 to this files.

RUN chmod 755 ./wkhtmltopdf/Linux/wkhtmltopdf RUN chmod 755 ./wkhtmltopdf/Linux/wkhtmltoimage

I use asp.net core 3.1

My images and css are stored in Azure Storage.

krlosmederos commented 4 years ago

Updated: If you execute wkhtmltopdf command inside container then styles and images are render ok. I tried sending multiple arguments to wkhtmltopdf from .net but i don't resolve the problem.

fpanaccia commented 4 years ago

Hi!, What is the command you ran on the console? Have you checked if is not a path issue? Can you upload an example?

You say that with 3.1 is not working, with a previous version it worked correctly? if yes, which one?

krlosmederos commented 4 years ago

Hi, not is a path issue, is a problem with ssl libraries and net core 3.1, betwen the breaking changes in net core 3.1 is change openssl 1.0 by openssl 1.1 If i install latest wkhtmltopdf version (0.12.5) sudo apt-get install xvfb libfontconfig wkhtmltopdf in the container and execute wkhtmltopdf then generate pdf ok, but with the generic build wkhtmltopdf i get error. The problem is with files in https.

In the site official de wkhtmltopdf says:

Where are the “generic” Linux builds? The above binaries depend on packages provided by your distribution. Due to incompatibilities between library versions (specifically OpenSSL) provided by each distribution, the only option is to use static linking which isn’t recommended for OpenSSL – hence removed for now.

Sorry for my english :(

krlosmederos commented 4 years ago

This is a snapshot with the error image

I added this in WkhtmltopdfDriver class

                string error = proc.StandardError.ReadToEnd();
                ILogger _logger = Log.ForContext(typeof(WkhtmltopdfDriverPersonalized));

                _logger.Warning(error);

                if (ms.Length == 0)
                {
                    throw new Exception(error);
                }
krlosmederos commented 4 years ago

I solved the problem, not calling the generic, i calling the wkhtmltopdf that I installed with apt-get

proc.StartInfo = new ProcessStartInfo
                    {
                        FileName = "wkhtmltopdf",
                        Arguments = switches,
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError = true,
                        RedirectStandardInput = true,
                        CreateNoWindow = true
                    };
fpanaccia commented 4 years ago

Veo que te llamas carlos y sos de chile, asi que asumo que hablas español jaja

Que raro que sea un tema de ssl, lo corri pidiendo cosas de ssl y por ahora no me rompio...voy a hacer un par de pruebas, el tema de instalar la libreria por apt-get era que no era headless (o habia un problema con eso, hace tanto lo hice que ya ni me acuerdo jaja)

hago un par de pruebas y te comento

fpanaccia commented 4 years ago

bueno...basicamente arme una vista de prueba de una imagen, y le puse bootstrap y una imagen sacada de un server con https...

Desde windows

image

Desde linux

image

Asi que confirmo el error

fpanaccia commented 4 years ago

Arreglado para que funcione dentro del container

image

Basicamente actualizando la libreria te funciona (ahora las subo actualizadas), por otro lado voy a meter un par de mejoras cuando le envias por parametro que libreria de wkhtml queres usar

fpanaccia commented 4 years ago

Ahi hice el push al proyecto de ejemplo el update https://github.com/fpanaccia/Wkhtmltopdf.NetCore.Example

Despues meto los otros cambios que te comente,

Saludos!

Pd: si tenes algun problema avisame por aca o levanta otro caso

krlosmederos commented 4 years ago

Buena, te pasaste, menos mal que pasamos al español, revisaré su actualización, lo probaré y le comento por aquí. Muchas gracias por la rápida respuesta. Saludos.

Update: Solucionado el issue. Muchas gracias

fpanaccia commented 4 years ago

por nada!