当前位置: 首页 > news >正文

Springboot 整合 itext 实现PDF文件合并,识别图片则转成PDF拼接

目录

  • 前言
  • 一、引用依赖
  • 二、使用步骤
    • 1.Controller
    • 2.Service接口
    • 3.实现类
  • 三、请求接口及结果


前言

本文实现 Springboot 整合 itext 实现PDF文件合并,图片转PDF拼接。


一、引用依赖

<dependency><groupId>com.itextpdf</groupId><artifactId>itext7-core</artifactId><version>8.0.5</version><type>pom</type>
</dependency>

二、使用步骤

1.Controller

代码如下(示例):

import com.ruoyi.tools.service.IPdfHandlerService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;import javax.servlet.http.HttpServletResponse;
import java.util.List;@RestController
@RequiredArgsConstructor
@RequestMapping("/pdf")
public class PdfHandlerController {private final IPdfHandlerService pdfHandlerService;@PostMapping(value = "/generateFromFiles", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public void uploadFiles(@RequestPart("files") List<MultipartFile> files, HttpServletResponse response) throws Exception {byte[] pdfBytes = pdfHandlerService.generatePdfFromFiles(files
http://www.lryc.cn/news/484565.html

相关文章:

  • TypeScript 中的 ! 和 ? 操作符
  • 开源三代示波器的高速波形刷新方案开源,支持VNC远程桌面,手机,Pad,电脑均可访问(2024-11-11)
  • 谷歌推出设备内置人工智能,实时向手机用户发出诈骗电话警报
  • AI换人脸facefusion项目口型同步‌API化改造及部署
  • 移动端问题
  • Linux网络——网络初识
  • 从华为到创业公司
  • Vue 组件通信及进阶语法
  • vue文本高亮处理
  • androidstudio入门到放弃配置
  • NLP论文速读(谷歌出品)|缩放LLM推理的自动化过程验证器
  • 【Linux学习】【Ubuntu入门】1-4 ubuntu终端操作与shell命令1
  • 【Qt】Qt在窗口中加载Web界面的方法汇总
  • Java集合框架之Collection集合遍历
  • 基于STM32的智能充电桩:集成RTOS、MQTT与SQLite的先进管理系统设计思路
  • windows 查看yolo11 是否安装了cuda
  • 机器学习【激活函数】
  • 【OpenEuler】配置虚拟ip
  • 数据分析师证书怎么考
  • 【人工智能】text2vec-large-chinese模型搭建本地知识库
  • 前端入门一之ES6--递归、浅拷贝与深拷贝、正则表达式、es6、解构赋值、箭头函数、剩余参数、String、Set
  • DevOps工程技术价值流:加速业务价值流的落地实践与深度赋能
  • IP数据云 识别和分析tor、proxy等各类型代理
  • vue2 自动化部署 shell 脚本
  • 服务器数据恢复——Ext4文件系统使用fsck后mount不上的数据恢复案例
  • CTF攻防世界小白刷题自学笔记14
  • 家政服务小程序,家政行业数字化发展下的优势
  • Springboot如何打包部署服务器
  • ubuntu将firewall-config导出为.deb文件
  • C++算法练习-day40——617.合并二叉树