| | |
| | | acroFields.setField(key, hashMap.get(key)); |
| | | } |
| | | pdfStamper.setFormFlattening(true); |
| | | |
| | | String isOpenSfzImg = sysConfigService.selectConfigByKey("pdf_isOpenSfzImg"); |
| | | String pathSfzfilePath = sysConfigService.selectConfigByKey("path_sfzfilePath"); |
| | | if (StrUtil.isNotBlank(isOpenSfzImg) && isOpenSfzImg.equalsIgnoreCase("y")){ |
| | | if (StrUtil.isNotBlank(pathSfzfilePath)){ |
| | | String key = DataSourceContextHolder.getDataSourceKey(); |
| | | key = key.replace("ltkjpeis10_",""); |
| | | if (new File(pathSfzfilePath + File.separator + key + File.separator+customer.getCusId()+".png").exists()) { |
| | | String pdfSfzimgwidth = sysConfigService.selectConfigByKey("pdf_sfzimgwidth"); |
| | | String pdfSfzimgheight = sysConfigService.selectConfigByKey("pdf_sfzimgheight"); |
| | | String pdfSfzimgy = sysConfigService.selectConfigByKey("pdf_sfzimgy"); |
| | | String pdfSfzimgx = sysConfigService.selectConfigByKey("pdf_sfzimgx"); |
| | | int width = 100,height = 100,x = 90,y = 180; |
| | | if (StrUtil.isNotBlank(pdfSfzimgwidth)) { |
| | | width = Integer.parseInt(pdfSfzimgwidth); |
| | | } |
| | | if (StrUtil.isNotBlank(pdfSfzimgheight)) { |
| | | height = Integer.parseInt(pdfSfzimgheight); |
| | | } |
| | | if (StrUtil.isNotBlank(pdfSfzimgy)) { |
| | | y = Integer.parseInt(pdfSfzimgy); |
| | | } |
| | | if (StrUtil.isNotBlank(pdfSfzimgx)) { |
| | | x = Integer.parseInt(pdfSfzimgx); |
| | | } |
| | | Image image = Image.getInstance(pathSfzfilePath + File.separator + key + File.separator+customer.getCusId()+".png"); |
| | | // 设置图片位置和大小 |
| | | // image.setAbsolutePosition(90, 190); // 表单左边 |
| | | // image.setAbsolutePosition(495, 742); // 右上角 |
| | | // image.setAbsolutePosition(250, 50); // 中下 |
| | | image.setAbsolutePosition(x, y); |
| | | image.scaleAbsolute(width, height); // 设置图片宽度和高度 |
| | | PdfContentByte content = pdfStamper.getOverContent(1); |
| | | content.addImage(image); |
| | | } |
| | | } |
| | | } |
| | | |
| | | pdfStamper.close(); |
| | | reader4.close(); |
| | | // 将修改后的PDF内容写入 |