简体   繁体   中英

Saving PDF's generated with flying-saucer directly to /resources or any other folder

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?

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");

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM