Skip to content
New issue

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

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

Already on GitHub? # to your account

how let go-wkhtmltopdf know where is wkhtmltox/pdf.h #35

Open
rdhmuhammad opened this issue May 18, 2023 · 3 comments
Open

how let go-wkhtmltopdf know where is wkhtmltox/pdf.h #35

rdhmuhammad opened this issue May 18, 2023 · 3 comments

Comments

@rdhmuhammad
Copy link

hi man, sorry i dont where else to ask this, the repo where i used the wkhtmltopdf image not responding the issue.

So, i try to use wkhtmltopdf on my dockerfile which look like this

FROM ghcr.io/surnet/alpine-wkhtmltopdf:3.17.0-0.12.6-small as wkhtmltopdf
FROM golang:1.19.9-alpine3.17

# Install dependencies for wkhtmltopdf
RUN apk add --no-cache \
    libstdc++ libx11  libxrender  libxext libssl1.1 
    ca-certificates fontconfig freetype ttf-dejavu \
    ttf-droid ttf-freefont ttf-liberation \
    # more fonts
  && apk add --no-cache --virtual .build-deps \
    msttcorefonts-installer \
  # Install microsoft fonts
  && update-ms-fonts \
  && fc-cache -f \
  # Clean up when done
  && rm -rf /tmp/* \
  && apk del .build-deps \

COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/wkhtmltopdf
COPY --from=wkhtmltopdf /bin/libwkhtmltox* /bin/

WORKDIR /src
COPY . .
RUN go mod vendor && go mod verify
RUN go build -o main .

EXPOSE 8080

CMD ["./main"]

which totally fine when i havent install https://github.com/adrg/go-wkhtmltopdf but when i install it and build again. its always throws this error error during docker build.

> [builder 7/7] RUN go build -o /app-bin /src/main.go:
#0 3.510 # github.com/adrg/go-wkhtmltopdf
#0 3.510 vendor/github.com/adrg/go-wkhtmltopdf/converter.go:7:10: fatal error: wkhtmltox/pdf.h: No such file or directory
#0 3.510     7 | #include <wkhtmltox/pdf.h>
#0 3.510       |          ^~~~~~~~~~~~~~~~~
#0 3.510 compilation terminated

do you know how to let the go compiler where the wkhtmltox is ?
i've stry specify cgo flags but still doesnt work

i really appreciate your answer,

@mateusfmello
Copy link

I have the same problem

@mateusfmello
Copy link

The solution I found was this:

Links:

  1. https://github.com/adrg/go-wkhtmltopdf/wiki/Install-on-Linux
  2. https://wkhtmltopdf.org/downloads.html

In this case it was simple, all that was missing was to install "wkhtmltox", I followed the documentation and it worked perfectly.

sudo apt-get install xfonts-75dpi

Download the corresponding file that is available at link 2

sudo dpkg -i wkhtmltox.deb

Remember to change "wkhtmltox.deb" to the full path to the previously downloaded package file

sudo ldconfig

After that I ran my system and it worked perfectly, the result is amazing, congratulations to everyone working on this project

@MicahParks
Copy link
Contributor

This is the Dockerfile I am currently using.

FROM golang:bullseye
WORKDIR /app
RUN apt update && apt install xfonts-75dpi fontconfig libjpeg62-turbo libx11-6 libxcb1 libxext6 libxrender1 xfonts-base -y
COPY . .
# https://wkhtmltopdf.org/downloads.html
RUN dpkg -i ./wkhtmltox.deb
RUN ldconfig
RUN go build -o main cmd/server/main.go
CMD ["/app/main"]

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

No branches or pull requests

3 participants