Giter Club home page Giter Club logo

Comments (3)

byrialsen avatar byrialsen commented on June 8, 2024

I have this stack trace:

at System. Net.HttpWebRequest.EndGetResponse(lAsyncResult asyncResult)
at System.Net.WebClient.CetWebResponse(WebRequest request, IAsyncResult result)
at System. Net.WebClient.GetWebResponseTaskAsync(WebRequest request)
at System.Net.WebClient.DownloadBitsAsync(WebRequest request, Stream writeStream, AsyncOperation asyncOp, Action 3 completionDelegate)

at PuppeteerSharp.BrowserFetcher.DownloadAsync(String revision) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/puppeteerSharp/BrowserFetcher.cs:line 264

at Markdown2Pdf.Markdown2PdfConverter—CreateBrowserAsync()
at Markdown2Pdf.Markdown2PdfConverter._GeneratePdfAsync(String htmlFilePath, String outputFilePath)
at Markdown2Pdf.Markdown2PdfConverter.Convert(String markdownFilePath, String outputFilePath)
at Cockpit.Core.Services.FileService.GetReleaselnfoBinaryPdfAsync(CancellationToken cancellationToken) in c:\projects\pc\colleqx2\cockpit\source\core\services\Fileservice.cs:line 114

Do I understand it correctly that this converter needs chromium to be available and inside docker container (Linux dist) this is not the case. Also my docker invironment is hosted on a closed eco-system without internet access, thus I can not use this component. Right ?

from markdown2pdf.

Flayms avatar Flayms commented on June 8, 2024

Yeah you're right, this package uses PuppeteerSharp to render the PDF, which needs a headless chrome/-ium. Once you have chrome and the specified npm packages though, no internet access is needed.

I haven't completely tested the Linux support but I was assuming it works bc the Github tests are also running on Ubuntu. When I am testing the package with an Ubuntu 22.04 Docker Container though I am also getting the PuppeteerSharp Exception, even with Chromium installed.

Gonna investigate this further.

from markdown2pdf.

Flayms avatar Flayms commented on June 8, 2024

Try using Markdown2Pdf v1.3.0 and add the following to your dockerfile (see running in docker):

RUN apt-get update \
    && apt-get install -y w3m \
    && apt-get install -y wget gnupg \
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update \
    && apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
      --no-install-recommends \
    && rm -rf /var/lib/apt/lists/*

To run the container without internet access you also need to install chrome / chromium via the dockerfile.
Then use Markdown2Pdf with the following options:

var options = new Markdown2PdfOptions {
  ChromePath = "path-to-chrome",
  ModuleOptions = ModuleOptions.FromLocalPath("path-to-node_modules"),
};

Note that without internet the node_modules also need to be installed seperately

from markdown2pdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.