base64 -> multipartFile
/**
* 将 图片base64 - > MultipartFile
* @param base64
* @return
*/
public static MultipartFile base64MultipartFile(String base64) {
try {
String[] baseStr = base64.split(",");
BASE64Decoder base64Decoder = new BASE64Decoder();
byte[] b;
b = base64Decoder.decodeBuffer(baseStr[1]);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
return new BASE64DecodedMultipartFile(b, baseStr[0]);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
multipartFile - > pdf
/**
* 将图片转换为PDF文件
*
* @param file SpringMVC获取的图片文件
* @return PDF文件
* @throws IOException IO异常
* @throws DocumentException PDF文档异常
*/
private static File generatePdfFile(MultipartFile file) throws IOException, DocumentException {
String fileName = file.getOriginalFilename();
String pdfFileName;
if (fileName != null) {
pdfFileName = fileName.substring(0, fileName.lastIndexOf(".")) + ".pdf";
} else {
return null;
}
Document doc = new Document(PageSize.A4, 100, 100, 20, 30);
PdfWriter.getInstance(doc, new FileOutputStream(pdfFileName));
doc.open();
doc.newPage();
Image image = Image.getInstance(file.getBytes());
float height = image.getHeight();
float width = image.getWidth();
int percent = getPercent(height, width);
image.setAlignment(Image.MIDDLE);
image.scalePercent(percent);
doc.add(image);
doc.close();
return new File(pdfFileName);
}
/**
* 等比压缩,获取压缩百分比
* @param height 图片的高度
* @param weight 图片的宽度
* @return 压缩百分比
*/
private static int getPercent(float height, float weight) {
float percent;
if (height > weight) {
percent = PageSize.A4.getHeight() / height * 100;
} else {
percent = PageSize.A4.getWidth() / weight * 100;
}
// -5 多缩放一点 不影响内容
percent -= 5;
return Math.round(percent);
}
如果还需要转成multipartFile方便调用api上传的话
pdf file - > multipartFile
FileInputStream input = new FileInputStream(file);
MultipartFile multipartFilePDF = new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(input));
pom 依赖 itextpdf
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.10</version>
</dependency>
1. Demo初始界面2. 游戏界面3. 精确碰撞检測4. 下载 压缩文件文件夹AngryBird source 愤慨的小鸟Demo源码,基于Cocos2dx C++,以及box2d技术。run 可运行程序文件夹点击打开链接 ...
1:切换到你想要安装的目录:cd developer2:得到一个安装包,选择自己想要的版本:wget https://ffmpeg.org/releases/ffmpeg-4.1.tar.bz23:解压 tar -xjvf ffmpeg-4.1.tar.bz24:切换到解压好的目录中 cd ffmpeg-4.1/5:先安装 yasm :yum install yasm6:安装完毕以后...
假设我文件夹jni有一个list.sh文件我直接 nxgametekiMacBook-Air:jni luonan$ ./list.sh ../../Classes提示 permission denied然后chmod +x *.sh然后运行就OK了nxgametekiMacBook-Air:jni luonan$ chmod +x *.sh ./list.sh ../...
Standard Module List点击Module名字,可导航至python官方的Python Document相关模块说明。若是英文阅读吃力,可在参考本文件夹下相关模块内容后,再行阅读(可能也没必要阅读了)。以下列表,内置模块总计205个。嗯,所以当你用到的时候再来查阅就好了,单独全面学习的话,我也没说不好。。。___future__Future statement definitions__main__The environment where the
转自:http://4951507.blog.51cto.com/4941507/11087331、LoadRunner超时错误:在录制Web服务器端,如果超过120秒服务器协议脚本回放时超时情况经常出现,产生错误的原因也有很多,解决的方法也不同。错误现象1:Action.c(16): Error -27728: Step download timeout (120 seconds) has ...
硬件:STM32F103SG90MPU6050OLED具体程序和云台效果:https://www.bilibili.com/video/BV1S7411m7eu/
有什么适合大学生搜题的一些APP,比如解决高数,线代,数学建模,大学物理这样的学科问题的APP?您可以使用quark或百度直接搜索对于高级数字,您可以使用“Microsoft math”或photomath,但这需要一点高扫描角度;您也可以尝试wellframe Alpha家庭作业帮助,小猿猴搜索的题目可以在一些题目里找到微信小程序也可以试试课本上的题目可以试试“帮班宝”、“学小容易”APP有一些...
如果系统中有一些配置文件在服务器上做了配置修改,然后后续开发又新添加一些配置项的时候,在发布这个配置文件的时候,会发生代码冲突:error: Your local changes to the following files would be overwritten by merge:protected/config/main.phpPlease, commit your changes...
1,确认安装mysql(本人用的5.1版本)2,下载mysql-connector-net-5.2.3并安装,地址:http://dev.mysql.com/downloads/connector/net/5.2.html 里面集成了MySQL Visual Studio Plugin,而mysql-connector-net-5.0不集成.3,到这步为止,已经可以用vs菜单里"工具
jsp阶段:&lt;audio controls="controls" controlsList="nodownload"&gt;&lt;source src="${ctx }/phone/getAudio.ce?type=3&amp;PATHID='+mp+'" type="audio/mpeg"&gt;&lt;/audio&gt;效果图:java部分:@Request
看看这位大佬的
前言大家对支付漏洞的理解通常都是篡改价格,已有的对支付漏洞的总结也是对现有的一些案例的经验式归类,没有上升到对在线支付流程深入分析的一个层面。这里尝试从分析在线支付流程,在线支付厂商的接入方式开始,深入业务分析整个在线交易流程中容易出现的安全问题。支付宝/在线支付流程支付宝即时到账接口开发流程在线支付从功能上来说是通过支付宝的支付渠道,付款者直接汇款给另一个拥有支付宝账号的收款者。