Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images not working when using from ubuntu docker #85

Open
sconci opened this issue Mar 20, 2023 · 3 comments
Open

Images not working when using from ubuntu docker #85

sconci opened this issue Mar 20, 2023 · 3 comments

Comments

@sconci
Copy link

sconci commented Mar 20, 2023

Hello,

Not sure if someone struggled with this. I'm testing the library from Windows and have no problems rendering pdfs with links to external public images, but when deploying to an ubuntu docker, images are not shown in the pdf generated. Checked all the permissions to the libraries and I have no problem.

I made sure the docker has internet access and gave permissions to both wkhtmltopdf and wkhtmltoimage
(followed this link: #17)

does anyone have any idea?

Thanks!

@willpower18
Copy link

Hi, the wkhtmltopdf on linux needs some packages to work fine, if you installed the package (wkhtmltopdf.deb) in you pc and just copied the file wkhtmltopdf to the application folder, this can cause some problems. The correct is you extract and install the package in the docker image and install all dependencies. Here it work fine to me. but I use one abstraction of docker, my application runs in azure linux web app.

try these steps:

  1. open the cmd

docker exec -u 0 -it mycontainer bash

  1. update the packages

apt-get update

  1. install sudo

apt-get -y install sudo

  1. unpack the package

dpkg -i wkhtmltox.deb

  1. install the dependencies

apt-get -f install

  1. unpack the package again

dpkg -i wkhtmltox.deb

  1. copy the generated file to your application folder

sudo cp /usr/local/bin/wkhtmltopdf ~/site/wwwroot/wwwroot/Rotativa

@RGalli
Copy link

RGalli commented Oct 20, 2023

Install the packages with a script similar to this:

#!/bin/sh
apt update
apt -y install wget
### Debian 10 ### (change to your operating system)
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb
apt install -f -y ./wkhtmltox_0.12.6-1.buster_amd64.deb
### Copy files ###
cp -f /usr/local/bin/wkhtmltopdf ~/site/wwwroot/wwwroot/Rotativa
cp -f /usr/local/bin/wkhtmltoimage ~/site/wwwroot/wwwroot/Rotativa

@ArjanKw
Copy link

ArjanKw commented Aug 16, 2024

This is probably because Rotativa injects the base URL property in your HTML. See #60 (comment) . The base URL is set to the internal port your website is listening to, but that port is only accessible by docker. Another port is used for incoming requests.

Setting the base URL by Rotativa shouldn't be necessary, as in my opinion you should set the base URL yourself in the HTML if your site needs it. In PR #92 an option is added to disable setting the base URL (setBaseUrl: false), which should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants