HTML to PDF Action - NodeJS & PHP [Open Source]

Thank you for such a cool extension, much appreciated.

I have one in mind that I might create and share for PDF.

Is there documentation on using the custom.hjson to extend the custom module ?

1 Like

Please refer this:

This looks really amazing. Can anyone share how to install this into an existing node.js project? Ive already installed Puppeteer, I just donā€™t know what to do next.

You just need to add the HJSON & JS files to the extension folder in your project. Its quite simple.
Refer the links to Wappler documentation in the main post for more details.

Thank you. Ive been tinkering with the whole project from gitlab. Amazing! Working on getting it into my project today.

1 Like

Hey @sid trying to get this up and running today, but, Iā€™m getting the following error after deploying with these docker file changes. Any ideas?

failed to solve: process "/bin/sh -c apt-get update     && 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/*" did not complete successfully: exit code: 100
Error Launching Services!

I have seen this before from what I recollect. It was due to some package not being available from the list.

This is one of the scripts I am using currentlyā€¦ not sure if anything has changed:

RUN apt-get -qq update && \
	apt-get -qq install -y ca-certificates vim zip unzip pdftk && \
    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 -qq update \
    && apt-get -qq 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/* \
	&& apt-get -qq autoclean -y && \
	apt-get -qq autoremove -y

I also found this: https://stackoverflow.com/questions/52449765/docker-the-command-bin-sh-c-apt-get-install-nodejs-returned-a-non-zero-co, which might be relevant.

thanks @sid , can you share the full docker file so I place this correctly, as I see no npm install in your script, for example.

Also, is all of that code relevant solely to getting puppeteer working, or do I only need the google-chrome-stable line?

The code I shared is the puppeteer relevant code.
Hereā€™s my complete dockerfile:

FROM node:16.18.1

RUN apt-get -qq update && \
	apt-get -qq install -y ca-certificates vim zip unzip pdftk && \
    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 -qq update \
    && apt-get -qq 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/* \
	&& apt-get -qq autoclean -y && \
	apt-get -qq autoremove -y

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY ./package.json /usr/src/app/
RUN npm install && npm cache clean --force
COPY ./ /usr/src/app
ENV NODE_ENV development
ENV PORT 80
EXPOSE 80
CMD [ "npm", "start" ]

This is not a Wappler dockerfileā€¦ but a Caprover dockerfileā€¦ so there might be some differences.

ah ok - yeah there is. I have little experience with these files, so a little nervous to edit them (hence asking to see the full file) - iā€™ll try and do some learning, or perhaps work on a different html>pdf. Thank you Sid, I always appreciate your efforts in replying.

1 Like

Hello, can you provide me any help to install your HTML to PDF extension. Is the first time I will use a custom extension and no idea where to start.

Thanks but where to find the NPM for HTML to URL??

Sorry, canā€™t help. I have never installed a third party extension. In my mind, if Wappler canā€™t do it, I probably donā€™t need it.

Wappler canā€™t guarantee they will always work with Wappler as well. So I would be cautious about using a third party extension in my opinion.

Please read the original post. It has all the info.
There are two ways to do this - one is manually, and other is through NPM (which is what Brad has shared, but it not supported by any of our extensions).

1 Like

Thanks for developing this great extension. I had to modify the HtmlToPDF.js file to decode the html from the input because I needed to encode the html content before posting to the the server action API.

 var html =  "<style>body { padding: 0 !important; margin: 0 !important}</style>" +   decodeURIComponent(options.bodyHTML);
3 Likes

Weā€™ve integrated a client-side App Connect PDF Creator component in Wappler 6.3.0
Please check it and let us know what do you think: Using App Connect PDF Creator

Note that more options will be coming to it in the next updates!

1 Like