How to merge two PDF files without leaving blank spaces between its content

I need to merge two pdf files, in my case, the second must start where the first ends. I mean, it can not exist blank spaces between the content of the two files. At this time i can merge it but the content of the second starts on a new page

const newPdfDoc = await PDFDocument.load(newPdfArrayBuffer);
    for (let i = 0; i < newPdfDoc.getPageCount(); i++) {
    const [newPage] = await pdfDoc.copyPages(newPdfDoc, [i]);
        //...
        //. some stuff like scale, setFonts, fontSizes, etc 
        //...
    }
    pdfDoc.addPage(newPage);