Code Snippets-merge-pdfs

Merge Multipe PDFs

Merging multiple PDFs into a single document can be a time-consuming task, but CustomJS makes it easy and efficient. In this example, HTML strings are first converted into PDFs using the HTML2PDF function and then merged into a single document using the PDF_MERGE function.

This approach allows you to dynamically generate PDFs from HTML content and combine them seamlessly. It is perfect for automating PDF creation and merging in various workflows and saves both time and effort in your processes.

To optimize the process, we perform the merge asynchronously, to ensure that the task is completed faster, the PDFs are generated in parallel.
Merge Multiple PDFs With Make.com
Merge Multiple PDFs With Make.com
const { PDF_MERGE, HTML2PDF } = require('./utils');

let pages = [
    input.page1,
    input.page2,
    input.page3,
    input.page4,
    input.page5,
    input.page6,
    input.page7,
    input.page8,
    input.page9,
    input.page10,
    input.page11
];

pages = await Promise.all(pages.filter(i => i).map(i => HTML2PDF(i)));

return PDF_MERGE(pages);
Merge multiple PDFs With Make.com
Merge multiple PDFs With Make.com