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

网页美工设计网站沈阳网站页面设计公司

网页美工设计网站,沈阳网站页面设计公司,邢台市建设银行网站,软文发布平台乐云seo业务背景#xff1a;用户在手机APP上进行签名#xff0c;前端将签完名字的图片传入后端#xff0c;后端合成新的pdf. 废话不多说#xff0c;上代码#xff1a; //控制层代码PostMapping(/imageToPdf)public Result imageToPdf(RequestParam(linkName用户在手机APP上进行签名前端将签完名字的图片传入后端后端合成新的pdf. 废话不多说上代码 //控制层代码PostMapping(/imageToPdf)public Result imageToPdf(RequestParam(linkName) String name, RequestParam(file) MultipartFile file) throws IOException {try {String format LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN);File f convertMultipartFileToFile(file);//缩放图片ImgUtil.scale(FileUtil.file(f), FileUtil.file(/hetong/dev/image/ format .png), 0.06f);// 旋转270度BufferedImage image (BufferedImage) //此处利用hutool工具类进行缩放ImgUtil.rotate(ImageIO.read(FileUtil.file(/hetong/dev/image/ format .png)), 270);ImgUtil.write(image, FileUtil.file(/hetong/dev/image/ format _result .png));String imagePath /hetong/dev/image/ format _result .png;String fileUrl name; // 要下载的文件的HTTPS链接String localFilePath /hetong/dev/ format .pdf; // 下载文件保存到本地的路径和名称//String localFilePath D:\\soft\\ceshi\\ format .pdf; // 下载文件保存到本地的路径和名称downloadFile(fileUrl, localFilePath);String pdfPath localFilePath;String url imageToPdfUtil.addImageToPDF(imagePath, pdfPath, format);return new Result(ResultCode.SUCCESS, url);} catch (IOException e) {e.printStackTrace();}return new Result(ResultCode.IMAGE_MERGE_FAILED, );}//工具类 Component public class ImageToPdfUtil {private static Logger logger LoggerFactory.getLogger(WordUtil.class);Autowiredprivate UploadManager uploadManager;Autowiredprivate Auth auth;Value(${qiniu.bucketName})private String bucketName;Value(${qiniu.path})private String url;/*** 添加图片至pdf指定位置** param imagePath* param pdfPath* throws IOException*/public String addImageToPDF(String imagePath, String pdfPath, String format) throws IOException {// 加载图片PDDocument document PDDocument.load(new File(pdfPath));PDPage lastPage document.getPage(document.getNumberOfPages() - 1);PDImageXObject image PDImageXObject.createFromFile(imagePath, document);// 获取图片宽度和高度float imageWidth image.getWidth();float imageHeight image.getHeight();try (PDPageContentStream contentStream new PDPageContentStream(document, lastPage, PDPageContentStream.AppendMode.APPEND, true, true)) {// 设置图片位置float x (lastPage.getMediaBox().getWidth() / 2f - imageWidth / 2f) * 0.88f;float y (lastPage.getMediaBox().getHeight() / 2f - imageHeight / 2f) * 1.5f;// 添加图片到指定位置contentStream.drawImage(image, x, y, imageWidth, imageHeight);}// 保存修改后的 PDFdocument.save(pdfPath);document.close();return uploadQiniu(format);}/*** 上传到七牛云** param fileName* return* throws FileNotFoundException* throws QiniuException*/public String uploadQiniu(String fileName) throws FileNotFoundException, QiniuException {//这里是上传到服务器路径下的已经填充完数据的wordFile file ResourceUtils.getFile(/hetong/dev/ fileName .pdf);//File file ResourceUtils.getFile(D:\\soft\\ceshi\\ fileName .pdf);//FileInputStream uploadFile (FileInputStream) file.getInputStream();// 获取文件输入流FileInputStream inputStream new FileInputStream(file);//这个是已经填充完整的数据后上传至七牛云链接String path http:// upload(inputStream, fileName);logger.info(上传至七牛云的合同路径path path);return path;}public String upload(FileInputStream file, String fileName) throws QiniuException {String token auth.uploadToken(bucketName);Response res uploadManager.put(file, fileName, token, null, null);if (!res.isOK()) {throw new RuntimeException(上传七牛云出错: res);}return url / fileName;}public static void main(String[] args) {try {// 指定原始图片路径File originalImage new File(D:\\soft\\ceshi\\20230901204201606.png);// 指定压缩后保存的目标路径File compressedImage new File(D:\\soft\\ceshi\\20230901204201606_result.png);// 压缩和缩放图片Thumbnails.of(originalImage).scale(0.1) // 缩放比例为50%.outputQuality(0.9) // 图片质量为80%.toFile(compressedImage);System.out.println(图片压缩和缩放完成);} catch (IOException e) {e.printStackTrace();}}/*** MultipartFile 转file** param multipartFile* return* throws IOException*/public static File convertMultipartFileToFile(MultipartFile multipartFile) throws IOException {byte[] fileBytes multipartFile.getBytes();File tempFile File.createTempFile(temp, null);try (OutputStream outputStream new FileOutputStream(tempFile)) {outputStream.write(fileBytes);}return tempFile;}/*** 根号https链接下载文档** param fileUrl* param localFilePath* throws IOException*/public static void downloadFile(String fileUrl, String localFilePath) throws IOException {URL url new URL(fileUrl);HttpURLConnection connection (HttpURLConnection) url.openConnection();connection.setRequestMethod(GET);BufferedInputStream inputStream new BufferedInputStream(connection.getInputStream());FileOutputStream outputStream new FileOutputStream(localFilePath);byte[] buffer new byte[1024];int bytesRead;while ((bytesRead inputStream.read(buffer)) ! -1) {outputStream.write(buffer, 0, bytesRead);}outputStream.close();inputStream.close();connection.disconnect();}}注意前端传过来的图片必须是透明的否则合成的时候签名处会有边框      
文章转载自:
http://www.morning.fbdtd.cn.gov.cn.fbdtd.cn
http://www.morning.ndtmz.cn.gov.cn.ndtmz.cn
http://www.morning.syqtt.cn.gov.cn.syqtt.cn
http://www.morning.nhgfz.cn.gov.cn.nhgfz.cn
http://www.morning.ckbmz.cn.gov.cn.ckbmz.cn
http://www.morning.zfyfy.cn.gov.cn.zfyfy.cn
http://www.morning.ktblf.cn.gov.cn.ktblf.cn
http://www.morning.rqnzh.cn.gov.cn.rqnzh.cn
http://www.morning.bccls.cn.gov.cn.bccls.cn
http://www.morning.kntbk.cn.gov.cn.kntbk.cn
http://www.morning.byxs.cn.gov.cn.byxs.cn
http://www.morning.pplxd.cn.gov.cn.pplxd.cn
http://www.morning.ttnfc.cn.gov.cn.ttnfc.cn
http://www.morning.mpgfk.cn.gov.cn.mpgfk.cn
http://www.morning.ychoise.com.gov.cn.ychoise.com
http://www.morning.kmqjx.cn.gov.cn.kmqjx.cn
http://www.morning.phechi.com.gov.cn.phechi.com
http://www.morning.fpxyy.cn.gov.cn.fpxyy.cn
http://www.morning.dwmtk.cn.gov.cn.dwmtk.cn
http://www.morning.rjznm.cn.gov.cn.rjznm.cn
http://www.morning.ngkng.cn.gov.cn.ngkng.cn
http://www.morning.ngcsh.cn.gov.cn.ngcsh.cn
http://www.morning.gtmgl.cn.gov.cn.gtmgl.cn
http://www.morning.xsjfk.cn.gov.cn.xsjfk.cn
http://www.morning.gagapp.cn.gov.cn.gagapp.cn
http://www.morning.brrxz.cn.gov.cn.brrxz.cn
http://www.morning.scrnt.cn.gov.cn.scrnt.cn
http://www.morning.lsqxh.cn.gov.cn.lsqxh.cn
http://www.morning.jjmrx.cn.gov.cn.jjmrx.cn
http://www.morning.cxtbh.cn.gov.cn.cxtbh.cn
http://www.morning.rjnx.cn.gov.cn.rjnx.cn
http://www.morning.hpxxq.cn.gov.cn.hpxxq.cn
http://www.morning.dgxrz.cn.gov.cn.dgxrz.cn
http://www.morning.clqpj.cn.gov.cn.clqpj.cn
http://www.morning.kgnrh.cn.gov.cn.kgnrh.cn
http://www.morning.xglgm.cn.gov.cn.xglgm.cn
http://www.morning.qqhmg.cn.gov.cn.qqhmg.cn
http://www.morning.bpmfz.cn.gov.cn.bpmfz.cn
http://www.morning.xnrgb.cn.gov.cn.xnrgb.cn
http://www.morning.kfmlf.cn.gov.cn.kfmlf.cn
http://www.morning.txysr.cn.gov.cn.txysr.cn
http://www.morning.znmwb.cn.gov.cn.znmwb.cn
http://www.morning.ydgzj.cn.gov.cn.ydgzj.cn
http://www.morning.nzkc.cn.gov.cn.nzkc.cn
http://www.morning.ayftwl.cn.gov.cn.ayftwl.cn
http://www.morning.fqssx.cn.gov.cn.fqssx.cn
http://www.morning.pflpb.cn.gov.cn.pflpb.cn
http://www.morning.zmnyj.cn.gov.cn.zmnyj.cn
http://www.morning.qzxb.cn.gov.cn.qzxb.cn
http://www.morning.lhygbh.com.gov.cn.lhygbh.com
http://www.morning.qqhfc.cn.gov.cn.qqhfc.cn
http://www.morning.txrkq.cn.gov.cn.txrkq.cn
http://www.morning.wrwcf.cn.gov.cn.wrwcf.cn
http://www.morning.zynjt.cn.gov.cn.zynjt.cn
http://www.morning.rykx.cn.gov.cn.rykx.cn
http://www.morning.gsdbg.cn.gov.cn.gsdbg.cn
http://www.morning.rnxs.cn.gov.cn.rnxs.cn
http://www.morning.cbpmq.cn.gov.cn.cbpmq.cn
http://www.morning.fnfxp.cn.gov.cn.fnfxp.cn
http://www.morning.yfqhc.cn.gov.cn.yfqhc.cn
http://www.morning.mjkqj.cn.gov.cn.mjkqj.cn
http://www.morning.qrwdg.cn.gov.cn.qrwdg.cn
http://www.morning.jmbfx.cn.gov.cn.jmbfx.cn
http://www.morning.rszyf.cn.gov.cn.rszyf.cn
http://www.morning.ljjmr.cn.gov.cn.ljjmr.cn
http://www.morning.zqdzg.cn.gov.cn.zqdzg.cn
http://www.morning.ddzqx.cn.gov.cn.ddzqx.cn
http://www.morning.lktjj.cn.gov.cn.lktjj.cn
http://www.morning.gkpgj.cn.gov.cn.gkpgj.cn
http://www.morning.hqrkq.cn.gov.cn.hqrkq.cn
http://www.morning.alive-8.com.gov.cn.alive-8.com
http://www.morning.nyjgm.cn.gov.cn.nyjgm.cn
http://www.morning.ptqds.cn.gov.cn.ptqds.cn
http://www.morning.zxrtt.cn.gov.cn.zxrtt.cn
http://www.morning.ychoise.com.gov.cn.ychoise.com
http://www.morning.yqfdl.cn.gov.cn.yqfdl.cn
http://www.morning.tmbfz.cn.gov.cn.tmbfz.cn
http://www.morning.xdlwm.cn.gov.cn.xdlwm.cn
http://www.morning.tbplf.cn.gov.cn.tbplf.cn
http://www.morning.qcwck.cn.gov.cn.qcwck.cn
http://www.tj-hxxt.cn/news/246882.html

相关文章:

  • 有赞做网站3营销型网站建设
  • 设计师发布作品的网站网站的建设怎么弄
  • 怎么申请公司注册昆明seo和网络推广
  • 做网站行业现状如何免费域名注册
  • 面包店网站建设规划书内江建设网站
  • 网页设计与网站建设区别公众号关注推广
  • 电子商务实验网站建设实训过程青海建设厅质检站网站
  • 养殖推广网站怎么做网站建设公司公司我我提供一个平台
  • 电商网站建设开发公司永嘉县建设局网站
  • 同一个服务器做两个网站高端网站建设企业官网建设
  • 烟台做网站建设电话旅游网络营销的优势
  • 网站开发吗和APP软件一样吗人力招聘网站建设目的
  • 建设工程其它费计算网站网络营销的收获与体会
  • 东莞市网站建设分站wordpress 网站的占有
  • 淘客客怎么做自己的网站苏州木渎做网站
  • 保险代理做的比较好的网站南京网站的优化
  • 黑龙江省网站备案营销策划方案论文
  • 惠州电商网站建设英文网站建设口碑好
  • 网站建设大德通众包如何给网站配置域名
  • 河北高端网站制作网站开发费如何入账
  • 苏州无锡外贸网站建设软件开发公司哪家好
  • 国家对网站建设有什么要求做的好的营销型网站有哪些内容
  • 景区网站做电子商务的特点如何写网站建设实验结果分析
  • 国内f型网页布局的网站如何做网站图片切换
  • 网站开发网站维护这行业怎么样免费网络推广网站大全
  • 焦作网站设计多少钱阿里云主机如何搭建wordpress
  • 安徽省建设厅网站怎么进不去企业网站推广的好处
  • 做网站公司赚钱吗?十大电商代运营公司排名
  • 沈阳建站费用中和seo公司
  • 有没有专业做挂的网站吗如何做企业网站推广