| | |
| | | import freemarker.template.Template; |
| | | import freemarker.template.TemplateException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import net.coobird.thumbnailator.Thumbnails; |
| | | import org.apache.poi.util.Units; |
| | | import org.apache.poi.xwpf.usermodel.*; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | |
| | | |
| | | try (OutputStream out = new FileOutputStream(tempFile); |
| | | InputStream in = stream) { |
| | | Thumbnails.of(in).scale(0.8).rotate(270).outputFormat("jpg").toOutputStream(out); |
| | | byte[] buffer = new byte[1024]; |
| | | int length; |
| | | // 从原始流读取数据并写入临时文件 |
| | |
| | | out.write(buffer, 0, length); |
| | | } |
| | | } |
| | | |
| | | |
| | | //处理图片 |
| | | for (XWPFParagraph paragraph : document.getParagraphs()) { |
| | | List<XWPFRun> runs = paragraph.getRuns(); |