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

Running from docker throws exception #39

Closed
zhengfu1229 opened this issue Jun 19, 2020 · 6 comments
Closed

Running from docker throws exception #39

zhengfu1229 opened this issue Jun 19, 2020 · 6 comments
Labels

Comments

@zhengfu1229
Copy link

zhengfu1229 commented Jun 19, 2020

Hi,

I have a .net core project that is using ChromeHtmlToPdf. It works fine locally on windows. But it throws "no process is associated with this object" exception when running from docker container (which is linux based image).

The code is below:

var localPath = System.AppDomain.CurrentDomain.BaseDirectory + "testpage.html";
converter.ConvertToPdf(new ConvertUri(localPath), output, setting);

Does the project support docker?

@Sicos1977
Copy link
Owner

Sorry for the late respone but I never tested this project in a docker container. ChromeHtmlToPdf should run on Linux so it should be possible to run it in a docker container.

@Nongzhsh
Copy link

Nongzhsh commented Feb 9, 2022

It run in docker good.
You need to install Google browser.
This installation command works for me:

# Suppress an apt-key warning about standard out not being a terminal. Use in this script is safe.
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn

# export DEBIAN_FRONTEND="noninteractive"
ENV DEBIAN_FRONTEND noninteractive

# Install deps + add Chrome Stable + purge all the things
RUN apt-get update && apt-get install -y \
	apt-transport-https \
	ca-certificates \
	curl \
	gnupg \
	--no-install-recommends \
	&& curl -sSL https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
	&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
	&& apt-get update && apt-get install -y \
	google-chrome-stable \
	--no-install-recommends \
	&& apt-get purge --auto-remove -y curl gnupg \
	&& rm -rf /var/lib/apt/lists/*

# Chrome Driver
RUN apt-get update && \
    apt-get install -y unzip && \
    wget https://chromedriver.storage.googleapis.com/2.31/chromedriver_linux64.zip && \
    unzip chromedriver_linux64.zip && \
    mv chromedriver /usr/bin && rm -f chromedriver_linux64.zip

You may need to set google chrome args in your code:

using (var converter = new Converter())
{
       converter.AddChromeArgument("--no-sandbox");
       converter.ConvertToPdf(new ConvertUri(url), @".\Output\output.pdf", new PageSettings());
}

@Sicos1977
Copy link
Owner

Thanks for adding this

@mertulusan
Copy link

Hello, can you provide full dockerfile for building the application?

@Nongzhsh
Copy link

Nongzhsh commented Feb 13, 2022

@mertulusan Here can see the docker demo ChromeHtmlToPdf-netcoreapp2.2-docker

@mertulusan
Copy link

Thanks very much

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

No branches or pull requests

4 participants