0

Print and save more than 1 PDF

Hi there, hoping someone can help me. I have several different Print Layouts for one table and I would like to be able to press a button and have the system print all of them in one go and merge them in to one document. Is that possible without making a master print layout?

2 replies

null
    • Danjamesmedia
    • 1 yr ago
    • Reported - view

    This isn’t possible natively in Ninox.

    To merge a PDF then you’d need to use an external service such as cloudconvert via make.com.

    It’s important to bear in mind that the PDFs must be generated by human interaction inside Ninox rather than via make.com/API as PDF generation is a client-side feature only.

    • danielmarine
    • 1 mth ago
    • Reported - view

    Hi,

    The following formula displays a html button which achieves the desired result. Most of the functionality which Ninox currently misses can be worked around using the html() formula field and a bit of javascript. 

    You need URLs of each file you would like to combine. You then create a list of these URLs ensuring that they are separated by ','

    For example, if you had 3 pdf files the array would need to look like this, making sure to include the single quotes:

    'https://example1.pdf', 'https://example2.pdf', 'https://example3.pdf'

    See the code below:

    let URLarray := join(TABLE1.'YOUR_IMAGE_URL_FIELD', "','");

    html("<!DOCTYPE html>
    <html lang=""en"">
    <head>
        <meta charset=""UTF-8"">
        <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
        <title>Combine PDF Files from URLs</title>
    </head>
    <body>
        <button onclick=""combinePDF()"">Combine PDF Files from URLs</button>

        <script src=""https://cdnjs.cloudflare.com/ajax/libs/pdf-lib/1.16.0/pdf-lib.min.js""></script>
        <script>
            async function combinePDF() {
                const urls = [
    " +
    URLarray +
    "
                ];

                const pdfDoc = await PDFLib.PDFDocument.create();

                for (let i = 0; i < urls.length; i++) {
                    const response = await fetch(urls[i]);
                    const arrayBuffer = await response.arrayBuffer();
                    const tempPdfDoc = await PDFLib.PDFDocument.load(arrayBuffer);
                    const copiedPages = await pdfDoc.copyPages(tempPdfDoc, tempPdfDoc.getPageIndices());
                    copiedPages.forEach((page) => pdfDoc.addPage(page));

    if (i === urls.length - 1) {
                        const pdfBytes = await pdfDoc.save();
                        const blob = new Blob([pdfBytes], { type: ""application/pdf"" });
                        const url = URL.createObjectURL(blob);
                        const a = document.createElement(""a"");
                        a.href = url;
                        a.download = ""combined.pdf"";
                        a.click();
                    }
                }
            }
        </script>
    </body>
    </html>

Content aside

  • 1 mth agoLast active
  • 2Replies
  • 106Views
  • 3 Following