Code Monkey home page Code Monkey logo

Comments (41)

DennisdeBest avatar DennisdeBest commented on July 27, 2024 21

Hey to get this working in the mean time I used some of the dependencies mentioned in https://github.com/RoseRocket/docker-alpine-wkhtmltopdf-patched-qt

RUN apk --update --no-cache add \
   wkhtmltopdf \
    libgcc \
    libstdc++ \
    musl \
    qt5-qtbase \
    qt5-qtbase-x11 \
    qt5-qtsvg \
    qt5-qtwebkit \
    ttf-freefont \
    ttf-dejavu \
    ttf-droid \
    ttf-liberation \
    ttf-ubuntu-font-family \
    fontconfig

# Add openssl dependencies for wkhtmltopdf
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.8/main' >> /etc/apk/repositories && \
    apk add --no-cache libcrypto1.0 libssl1.0

This now works for me on a base php:7.4.12-fpm-alpine image.

It took a day of wondering around the internet to get this to work but it does now :)

Thanks @ashkulz for this librairie, it is awesome :)

from packaging.

alloylab avatar alloylab commented on July 27, 2024 7

yes I am, got behind with EOQ... just successfully compile 0.12.5 on alpine... https://git.alloylab.com/open-source/wkhtmltopdf/tags/0.12.5-070518 will submit PR on here

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024 4

I guess I'll need to incorporate the musl changes into Qt as well, as I don't want to apply patches on the fly ... will try to look into it this weekend.

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024 4

@alloylab: are you planning to make a PR for this?

from packaging.

chdanielmueller avatar chdanielmueller commented on July 27, 2024 4

@sir-gon or feel free to use https://github.com/Surnet/docker-wkhtmltopdf

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024 4

0.12.6 is released already -- an alpine version will only happen for 0.12.7.

from packaging.

reiz avatar reiz commented on July 27, 2024 3

Any updates on this?

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024 2

from packaging.

co-codr avatar co-codr commented on July 27, 2024 2

Any updates on release 0.12.6?

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024 2

I think there's a few docker images linked above, I've yet to evaluate the patches ๐Ÿคทโ€โ™‚๏ธ

from packaging.

jtraulle avatar jtraulle commented on July 27, 2024 1

@sir-gon See my Dockerfile for this : https://github.com/Opencomp/Dockerfiles/blob/master/wkhtmltopdf/Dockerfile

from packaging.

maggie44 avatar maggie44 commented on July 27, 2024 1

Hey to get this working in the mean time I used some of the dependencies mentioned in https://github.com/RoseRocket/docker-alpine-wkhtmltopdf-patched-qt

RUN apk --update --no-cache add \
   wkhtmltopdf \
    libgcc \
    libstdc++ \
    musl \
    qt5-qtbase \
    qt5-qtbase-x11 \
    qt5-qtsvg \
    qt5-qtwebkit \
    ttf-freefont \
    ttf-dejavu \
    ttf-droid \
    ttf-liberation \
    ttf-ubuntu-font-family \
    fontconfig

# Add openssl dependencies for wkhtmltopdf
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.8/main' >> /etc/apk/repositories && \
    apk add --no-cache libcrypto1.0 libssl1.0

This now works for me on a base php:7.4.12-fpm-alpine image.

It took a day of wondering around the internet to get this to work but it does now :)

Thanks @ashkulz for this librairie, it is awesome :)

@ashkulz, would be helpful to hear your view on this approach. Am I opening a can of worms using this for a production env? Is it best to wait for .7 release?

It would be for creating a pull request on a Linux Server image to resolve this issue: linuxserver/docker-bookstack#80

from packaging.

quentincaffeino avatar quentincaffeino commented on July 27, 2024 1

Sorry for asking. But this could be very useful for what I am currently working on (alpine images with wkhtmltopdf for amd and arm processors), so... Is there any update on this? ๐Ÿ˜…

If you want your pdf look pixel perfect as in browser, just use a browser and some testing framework. Here is an example how to do this with puppeteer' https://futurestud.io/tutorials/node-js-create-a-pdf-from-html-with-puppeteer-and-handlebars

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024

from packaging.

dcelasun avatar dcelasun commented on July 27, 2024

Any progress on this?

from packaging.

sir-gon avatar sir-gon commented on July 27, 2024

Oh pls! I i'm doing a lot of research for a headless solution for PDF generation and wkhtmltopdf is the best until now, but I have produced a huge docker image!

Alpine aproach would be perfect

from packaging.

mikehaertl avatar mikehaertl commented on July 27, 2024

@chdanielmueller @sir-gon But the font issue mentioned in the issue description still isn't fixedin the Surnet images, right? This makes those images only partially useful.

from packaging.

chdanielmueller avatar chdanielmueller commented on July 27, 2024

@mikehaertl That's right that issue is still open. A workaround is to use fonts loaded from the web. e.g. Google Fonts

@jtraulle Do you have any issues in your image with false fonts?

from packaging.

jtraulle avatar jtraulle commented on July 27, 2024

@chdanielmueller I don't think so. Try it a tell me ;)

from packaging.

cjimti avatar cjimti commented on July 27, 2024

I have not yet experienced any font issues. It is possible I may just be using my build on such a limited set of pages that I have not noticed it. I use a binary build for alpine:3.7 from https://github.com/madnight/docker-alpine-wkhtmltopdf and add fonts. My docker file is here: https://github.com/txn2/n2pdf/blob/master/Dockerfile

https://github.com/txn2/n2pdf

I use this pretty heavily in my txPdf project: https://imti.co/webpage-to-pdf-microservice/

from packaging.

enthusiasmus avatar enthusiasmus commented on July 27, 2024

Any progress so far? May we help with the pr?

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024

from packaging.

enthusiasmus avatar enthusiasmus commented on July 27, 2024

Is there a guide how to compile wkhtmltopdf for other platforms (alpine) and a testing guide to see if the build is working or not?

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024

Also, forgot about #20 by @anujith-singh -- it has the build system changes but I doubt it works because of the missing Qt patches.

from packaging.

anujith-singh avatar anujith-singh commented on July 27, 2024

Yes @ashkulz Qt patches are missing in it

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024

I'm planning to release 0.12.6 in a week's time -- does someone have the capacity to work with me to integrate the Qt patches required for Alpine support? @alloylab was going to do that at one point of time -- if he or @chdanielmueller can help me integrate the patches so that they don't break something else, I'd really appreciate it ๐Ÿ˜„

from packaging.

chdanielmueller avatar chdanielmueller commented on July 27, 2024

@ashkulz The file linked below is a Dockerfile for alpine:10 which builds 0.12.6
https://github.com/Surnet/docker-wkhtmltopdf/blob/master/archive/alpine-wkhtmltopdf/Dockerfile_3.10-0.12.6-full
I hope this is enough reference for a official alpine package for 0.12.7

With alpine:11 and up we have an issue that we are not able to build without specifically setting g++ and stdlibc++ to use the version from alpine:10.
The issue is related to gcc9.
Please see the following discussions:
Surnet/docker-wkhtmltopdf#13
Surnet/docker-wkhtmltopdf#18

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024

@chdanielmueller that's a common problem (affecting Ubuntu 20.04 and ArchLinux as well) -- I'll be solving that with a proper fix in Qt, the Q_FOREACH fix looks to be correct.

My main concern is integrating the other patches in https://github.com/Surnet/docker-wkhtmltopdf/tree/master/conf -- I'd like to understand why each one is required, as they shouldn't cause a regression for some other platform. Do you have some script/process that you use for testing the resulting binary, so I can confirm if the patch is required at compile time or at runtime and adapt accordingly?

from packaging.

chdanielmueller avatar chdanielmueller commented on July 27, 2024

I did not include any automated tests.
You can run the following command to test a version you built without some of the patches.
docker run surnet/alpine-wkhtmltopdf:<version> google.com - > test.pdf

The patches are being applied here:
https://github.com/Surnet/docker-wkhtmltopdf/blob/a445546703648957459b9c673e9db2e637c5a4de/Dockerfile-alpine.template#L53
(or in any Dockerfile in the archive)

from packaging.

darmawan01 avatar darmawan01 commented on July 27, 2024

any update for this issues ?
i use image alpine and wkhtmltopdf 0.12.5

look like is not patched with qt

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024

@darmawan01 not really, I haven't had time to integrate the musl patches into patched Qt.

from packaging.

darmawan01 avatar darmawan01 commented on July 27, 2024

i really need for this qt support in alpine. when the 12.7 will release with alpine build patched qt ?

from packaging.

taraspos avatar taraspos commented on July 27, 2024

@Maggie0002, issue I faced that Chinese text is not being rendered without wqy-zenhei package.

Ref: https://stackoverflow.com/a/49085451/3880239

from packaging.

itsyoshio avatar itsyoshio commented on July 27, 2024

Anyone managed to achieve QT5 Webkit compatibility?
The Arch Linux package is bundled for that, so it includes CSS3 (Flex) Support.

I'm wondering there is a docker image / guide or anything out here.

Thanks!

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024

Not really, haven't had the time to investigate the required Qt patches.

from packaging.

huycn avatar huycn commented on July 27, 2024

I would like to share some info which may help those who are still struggling with font issues. I'm not sure where the source of problem but it seems that it depends a lot on configuration of fontconfig. I have following test file:

<html>
<head>
<style>
@font-face {
    font-family: "Arial Narrow";
    src: url("arialn.ttf") format("truetype");
}
body { font-amily: "Arial" }
.narrow { font-family: "Arial Narrow" }
</style>
</head>
<body>
This text should be using Arial font.<br/>
<span class="narrow">This text should be using Arial Narrow font.</span><br/>
</body>
</html>

With docker image from https://github.com/Surnet/docker-wkhtmltopdf, if no fonts are installed, the pdf will have both lines with "Arial Narrow", which is reasonable. But if I install Arial in OS, the pdf will have both lines in Arial. Replace Arial with other font, it will have both lines in that font, ignoring completely the font-face in css.

Now if I extract the package fonts-urw-base35 from Ubuntu repo, copy files from /etc/fonts/config.d and from /usr/share/fonts/opentype/urw-base35 over to my docker image and do fc-cache -f, it starts to work correctly, each line with expected font. I guess the fallback configuration in config.d did the trick but I cannot confirm, it's good enough for me so I move on.

I also tested with ubuntu:focal, it had the same issue without the package fonts-urw-base35, but works correctly with.

from packaging.

ashkulz avatar ashkulz commented on July 27, 2024

@huycn that sounds like more a fontconfig issue with the above docker image and not wkhtmltopdf? Thanks for the information, though!

from packaging.

Ruesa18 avatar Ruesa18 commented on July 27, 2024

Sorry for asking. But this could be very useful for what I am currently working on (alpine images with wkhtmltopdf for amd and arm processors), so... Is there any update on this? ๐Ÿ˜…

from packaging.

Ruesa18 avatar Ruesa18 commented on July 27, 2024

I already have existing applications that are using wkhtmltopdf. The only thing is that I would like to have it inside my alpine images for easier deployment and maintenance in general. So switching to another pdf renderer isn't really an option ๐Ÿ˜…
What I'm searching is either an up-to-date alpine image (amd and arm) or - even better - binary files for both architectures that I can just download and copy into my existing images

from packaging.

quentincaffeino avatar quentincaffeino commented on July 27, 2024

I already have existing applications that are using wkhtmltopdf. The only thing is that I would like to have it inside my alpine images for easier deployment and maintenance in general. So switching to another pdf renderer isn't really an option ๐Ÿ˜…
What I'm searching is either an up-to-date alpine image (amd and arm) or - even better - binary files for both architectures that I can just download and copy into my existing images

I don't think there is a up-to-date binary therefore also no image. If it would be it would be here.

But you might be able to find older versions, just search for it, I used to use one myself.

from packaging.

huage969030970 avatar huage969030970 commented on July 27, 2024

I'm using this and it doesn't seem to support JavaScript

from packaging.

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.