0

I'am pretty new to java and spring MVC. I now can successfully create PDF Files with thymeleaf and flying-saucer like in this example: How to generate pdf Report using thymeleaf as template engine

In this example, files are stored in the local temp folder java.io.tempdir. My question is: How can i save these generated PDF's to my /resources directory or any other directory in my project?

2 Answers2

0

just specify the full path in your system properties. It works and make sure you have the folders in place.

System.getProperty("C://Documents//myfolder");
Zoe
  • 27,060
  • 21
  • 118
  • 148
0

In the example "out" is the path to file to be stored ,

getClass().getClassLoader().getResource(".").getFile()

will give resource folder location add your filename ,

pass

getClass().getClassLoader().getResource(".").getFile()+"/"+"yourfilename.ext"

as "out"

Srinivasan Sekar
  • 2,049
  • 13
  • 22
  • Accept if it helped you. – Srinivasan Sekar Apr 19 '19 at 11:18
  • So i applied these changes and used getClass().getClassLoader().getResource(".").getFile()+"myPDF.pdf" as the "out" in the method call. The application does run without error and confirmes, that it saved the PDF, but i can't find it anywhere in my project explorer. If i print the out statement i get something like this="*Projectname*/WEB-INF/classes//myPDF.pdf" – Julien Knepper Apr 19 '19 at 13:24
  • WEB-INF/classes/ is the location of the resources folder at run time @JulienKnepper you can see the file in target folder if your running from eclipse. – Srinivasan Sekar Apr 22 '19 at 05:07