With CustomJS, building an API for creating PDFs or screenshots of websites has never been easier. CustomJS acts as an efficient backend API solution that is a cost-effective alternative for PDF and screenshot generation compared to other providers.
You simply create a function, store your JavaScript code and then request it as an API. Below we show the JavaScript codes for creating PDFs from HTML strings or creating website screenshots. This solution offers seamless integration and great flexibility - all at a low cost.
If you want to do it with Make.com then learn more here.
You see that you only have to insert the code (which you see below), a dynamic parameter and set the response type to PDF/PNG. Then you can extract the payload and the URL of your function on the right side under “How To Use?” when you select POST JSON Request.
This code transforms a HTML string that is passed by a parameter into a PDF and returns it.
const { HTML2PDF } = require("./utils");
return HTML2PDF(input.html);
This code generates a screenshot from a URL that is passed as a parameter. The content of a binary PNG file is returned.
const { SCREENSHOT } = require('./utils');
return SCREENSHOT(input.url);