If you look at the code below, the file name was inserted when creating the document object.
If you don’t save it after performing logic, the file will not be deleted, so I wonder if you must save it.
Code
public Document mergePdf(Document mergedPdf, String pdfPath){
Document doc = new Document(pdfPath);
mergedPdf.getPages().add(doc.getPages());
//doc.save(pdfPath);
return mergedPdf;
}