**Please Guide me how to save the generated pdf in src/main/resources folder .** @Component public class PdfGenaratorUtil { @Autowired private TemplateEngine templateEngine; public String createPdf(String templateName, Map map) throws Exception { Assert.notNull(templateName, "The templateName can not be null"); Context ctx = new Context(); if (map != null) { Iterator> itMap = map.entrySet().iterator(); while (itMap.hasNext()) { Map.Entry pair = itMap.next(); ctx.setVariable(pair.getKey().toString(), pair.getValue()); } } String processedHtml = templateEngine.process(templateName, ctx); FileOutputStream os = null; String fileName = "POLIST "; try { final File outputFile = File.createTempFile(fileName, ".pdf", new File("C:\\Users\\ES001\\Desktop\\")); // Here I am saving in direct path os = new FileOutputStream(outputFile); ITextRenderer renderer = new ITextRenderer(); renderer.setDocumentFromString(processedHtml); renderer.layout(); renderer.createPDF(os, false); renderer.finishPDF(); System.out.println("PDF created successfully"); return outputFile.toString(); } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } } } }