我在询问之前已经搜索了很多。我创建了一个Jhipster微服务应用程序(v 3.12),我使用iText库基于模板生成我自己的PDF。
我在另一个项目中测试了GeneratePdfFromPdfTemplate class
(不是Spring Boot,而是一个简单的maven项目)并且效果很好;但是当我在JHipster项目中运行它时,新的FileOutputStream
指令会导致问题:
public static void generatePdf(String src,String dest,String codiceAvviso){
try {
PdfReader reader = new PdfReader(src);
FileOutputStream fos = new FileOutputStream(dest);
PdfStamper stamper = new PdfStamper(reader, fos);
PdfContentByte canvas = stamper.getOverContent(1);
...
当我调试它时,新的FileOutputStream(dest);强制重启我的应用程序导致此日志:
2017-04-05 14:15:50.160 INFO 12432 --- [ Thread-1] c.c.xenia.config.CacheConfiguration : Closing Cache Manager
2017-04-05 14:15:50.165 DEBUG 12432 --- [ Thread-1] c.e.c.E.consoft.xenia.domain.Authority : Close successful.
2017-04-05 14:15:50.166 DEBUG 12432 --- [ Thread-1] c.e.c.E.c.x.d.User.persistentTokens : Close successful.
2017-04-05 14:15:50.168 DEBUG 12432 --- [ Thread-1] .E.c.x.d.p.w.p.w.I.datiSingoloVersamento : Close successful.
2017-04-05 14:15:50.169 DEBUG 12432 --- [ Thread-1] c.e.c.E.c.x.d.p.w.p.w.InviaCarrPosOutput : Close successful.
2017-04-05 14:15:50.171 DEBUG 12432 --- [ Thread-1] .d.p.w.g.w.InserimentoPosizioneInputType : Close successful.
2017-04-05 14:15:50.172 DEBUG 12432 --- [ Thread-1] c.e.c.E.c.xenia.domain.PlacementTest : Close successful.
src和dest字符串分别是: SRC:
C:\用户\管理员\文件\的NetBeansProjects \捷尼亚\ SRC \主\资源\ templateAgid.pdf
DEST:
C:\用户\管理员\文件\的NetBeansProjects \捷尼亚\ SRC \主\资源\ Avviso_Pagamento_001385698469599575.pdf