With npm i ghostscript-node i get a valid PDF.
const gs = require("ghostscript-node"); async function afterRender(req, res) { // load PDF as Buffer const pdf1 = await downloadPDF('https://www.aubrete.lt/wp-content/uploads/2019/06/1-COVERSTYLE-1.pdf') // get number of pages of pdf1 const numPagesPDF1 = await gs.countPDFPages(pdf1); // get Buffer object with bytes of specified set of pages // page numbers begin with 1, last page is included const partOfPDF1 = await gs.extractPDFPages(pdf1, 1, numPagesPDF1); // checks if pdf1 is a valid PDF file const isPDF1Valid = await gs.isValidPDF(pdf1); if(isPDF1Valid) { res.content = await jsreport.pdfUtils.append(res.content, partOfPDF1) } }