获取页面传递字符
String data = req.getParameter("data");
String imageData=data.substring(data.indexOf(",")+2, data.length()-2);
//System.out.println(imageData.indexOf("\\"));
//String s="\\";
//imageData=imageData.replaceAll(s, " ");
imageData=imageData.replace('\\', ' ');
imageData=imageData.replaceAll(" \"", "\"");
//保存特定的目录下面 读取配置文件的路径
StringBuffer realPathDir = new StringBuffer();
realPathDir.append(PropertiesUtil.getProperty("SaveFilePath")+Constant.PACT.CAND_SIGNATURE);
String path = realPathDir.toString();
String filename=fix+candId+".png";
String imgPath = SvgPngConverter.convertToPng(imageData,path,path+"/"+filename);
SvgPngConverter.java
package com.qk365.util;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.PNGTranscoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.qk365.join.comp.action.CanditorMobileController;
/**
* 将svg转换为png格式的图片
*
*
*/
public abstract class SvgPngConverter {
private static Logger logger = LoggerFactory.getLogger(SvgPngConverter.class);
/**
* 将svg字符串转换为png
*
* @param svgCode svg代码
* @param pngFilePath 保存的路径
* @throws TranscoderException svg代码异常
* @throws IOException io错误
*/
public static String convertToPng(String svgCode, String filePah,String pngFilePath) throws IOException,
TranscoderException {
File fileFloder = new File(filePah);
if(!fileFloder.exists()){
fileFloder.mkdir();
}
//File file = new File(pngFilePath);
FileOutputStream outputStream = null;
try {
// file.createNewFile();
outputStream = new FileOutputStream(pngFilePath);
convertToPng(svgCode, outputStream);
return pngFilePath;
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
logger.error("outputStream.close e:",e);
return null;
}
}
}
}
/**
* 将svgCode转换成png文件,直接输出到流中
*
* @param svgCode svg代码
* @param outputStream 输出流
* @throws TranscoderException 异常
* @throws IOException io异常
*/
public static void convertToPng(String svgCode, OutputStream outputStream)
throws TranscoderException, IOException {
try {
byte[] bytes = svgCode.getBytes("utf-8");
PNGTranscoder t = new PNGTranscoder();
TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(bytes));
TranscoderOutput output = new TranscoderOutput(outputStream);
t.transcode(input, output);
outputStream.flush();
} finally {
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
StringBuffer sb=new StringBuffer();
// sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"><svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"401\" height=\"36\"><path fill=\"none\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M 1 1 c 2.12 0 80.27 -1.58 121 0 c 20 0.78 38.73 3.98 59 7 c 37.69 5.61 71.69 12.77 109 18 c 16.27 2.28 31.51 2.25 48 4 c 12.78 1.35 24.53 3.99 37 5 c 8.35 0.67 25 0 25 0\"/></svg>");
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"><svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"456\" height=\"132\"><path fill=\"none\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M 2 44 c -0.02 0.19 -1.72 7.99 -1 11 c 0.76 3.17 3.72 7.15 6 10 c 1.53 1.91 3.86 3.53 6 5 c 3.2 2.2 6.51 4.45 10 6 c 5.4 2.4 11.31 3.69 17 6 c 6.92 2.81 13.08 6.44 20 9 c 8.58 3.17 17.02 5.98 26 8 c 27.27 6.12 53.42 11.36 81 16 c 10.73 1.8 21.12 1.57 32 3 c 9.96 1.31 18.94 3.55 29 5 c 21.04 3.04 40.39 7 61 8 c 34.85 1.69 69.52 0.59 104 0 c 4.03 -0.07 7.97 -1.12 12 -2 c 3.77 -0.82 7.42 -1.75 11 -3 c 3.1 -1.08 6.13 -2.39 9 -4 c 5.5 -3.08 11.74 -6.06 16 -10 c 4.2 -3.89 7.74 -9.98 11 -15 c 0.94 -1.45 1.43 -3.29 2 -5 c 0.44 -1.31 1 -2.75 1 -4 c 0 -1.85 -0.12 -4.39 -1 -6 c -2.8 -5.14 -6.49 -11.97 -11 -16 c -10.32 -9.23 -23.9 -16.86 -36 -26 c -4.64 -3.5 -8.36 -7.61 -13 -11 c -7.86 -5.73 -15.83 -11.05 -24 -16 c -2.79 -1.69 -6.3 -2.38 -9 -4 c -2.14 -1.28 -3.91 -3.88 -6 -5 c -1.95 -1.05 -4.59 -1.4 -7 -2 c -1.69 -0.42 -3.44 -1 -5 -1 c -1.56 0 -3.66 0.19 -5 1 c -10.4 6.29 -22.47 14.1 -33 22 c -5.45 4.09 -9.76 10.12 -15 14 l -12 6\"/></svg>");
String m="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"><svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"456\" height=\"132\"><path fill=\"none\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M 2 44 c -0.02 0.19 -1.72 7.99 -1 11 c 0.76 3.17 3.72 7.15 6 10 c 1.53 1.91 3.86 3.53 6 5 c 3.2 2.2 6.51 4.45 10 6 c 5.4 2.4 11.31 3.69 17 6 c 6.92 2.81 13.08 6.44 20 9 c 8.58 3.17 17.02 5.98 26 8 c 27.27 6.12 53.42 11.36 81 16 c 10.73 1.8 21.12 1.57 32 3 c 9.96 1.31 18.94 3.55 29 5 c 21.04 3.04 40.39 7 61 8 c 34.85 1.69 69.52 0.59 104 0 c 4.03 -0.07 7.97 -1.12 12 -2 c 3.77 -0.82 7.42 -1.75 11 -3 c 3.1 -1.08 6.13 -2.39 9 -4 c 5.5 -3.08 11.74 -6.06 16 -10 c 4.2 -3.89 7.74 -9.98 11 -15 c 0.94 -1.45 1.43 -3.29 2 -5 c 0.44 -1.31 1 -2.75 1 -4 c 0 -1.85 -0.12 -4.39 -1 -6 c -2.8 -5.14 -6.49 -11.97 -11 -16 c -10.32 -9.23 -23.9 -16.86 -36 -26 c -4.64 -3.5 -8.36 -7.61 -13 -11 c -7.86 -5.73 -15.83 -11.05 -24 -16 c -2.79 -1.69 -6.3 -2.38 -9 -4 c -2.14 -1.28 -3.91 -3.88 -6 -5 c -1.95 -1.05 -4.59 -1.4 -7 -2 c -1.69 -0.42 -3.44 -1 -5 -1 c -1.56 0 -3.66 0.19 -5 1 c -10.4 6.29 -22.47 14.1 -33 22 c -5.45 4.09 -9.76 10.12 -15 14 l -12 6\"/></svg>";
//<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="456" height="132"><path fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M 2 44 c -0.02 0.19 -1.72 7.99 -1 11 c 0.76 3.17 3.72 7.15 6 10 c 1.53 1.91 3.86 3.53 6 5 c 3.2 2.2 6.51 4.45 10 6 c 5.4 2.4 11.31 3.69 17 6 c 6.92 2.81 13.08 6.44 20 9 c 8.58 3.17 17.02 5.98 26 8 c 27.27 6.12 53.42 11.36 81 16 c 10.73 1.8 21.12 1.57 32 3 c 9.96 1.31 18.94 3.55 29 5 c 21.04 3.04 40.39 7 61 8 c 34.85 1.69 69.52 0.59 104 0 c 4.03 -0.07 7.97 -1.12 12 -2 c 3.77 -0.82 7.42 -1.75 11 -3 c 3.1 -1.08 6.13 -2.39 9 -4 c 5.5 -3.08 11.74 -6.06 16 -10 c 4.2 -3.89 7.74 -9.98 11 -15 c 0.94 -1.45 1.43 -3.29 2 -5 c 0.44 -1.31 1 -2.75 1 -4 c 0 -1.85 -0.12 -4.39 -1 -6 c -2.8 -5.14 -6.49 -11.97 -11 -16 c -10.32 -9.23 -23.9 -16.86 -36 -26 c -4.64 -3.5 -8.36 -7.61 -13 -11 c -7.86 -5.73 -15.83 -11.05 -24 -16 c -2.79 -1.69 -6.3 -2.38 -9 -4 c -2.14 -1.28 -3.91 -3.88 -6 -5 c -1.95 -1.05 -4.59 -1.4 -7 -2 c -1.69 -0.42 -3.44 -1 -5 -1 c -1.56 0 -3.66 0.19 -5 1 c -10.4 6.29 -22.47 14.1 -33 22 c -5.45 4.09 -9.76 10.12 -15 14 l -12 6"/></svg>
//<?xml version= "1.0 " encoding= "UTF-8 " standalone= "no "?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN " "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd "><svg xmlns= "http://www.w3.org/2000/svg " version= "1.1 " width= "452 " height= "68 "><path fill= "none " stroke= "#000000 " stroke-width= "2 " stroke-linecap= "round " stroke-linejoin= "round " d= "M 1 1 c 0.39 0.3 14.23 11.67 22 17 c 10.55 7.23 20.85 14.18 32 20 c 11.91 6.21 24.32 10.98 37 16 c 5.27 2.09 10.45 3.52 16 5 c 9.88 2.63 19.3 5.35 29 7 c 5.86 1 11.8 0.92 18 1 c 20.97 0.27 40.16 0.47 61 0 c 9.25 -0.21 17.89 -0.86 27 -2 c 9.91 -1.24 19.3 -2.79 29 -5 c 9.6 -2.19 18.99 -4.56 28 -8 c 9.27 -3.54 17.58 -8.96 27 -13 c 14.53 -6.23 32.65 -16.83 43 -17 c 5.23 -0.09 11.29 11.28 17 16 c 1.64 1.36 3.98 2.27 6 3 c 1.54 0.56 3.33 0.93 5 1 c 6.55 0.26 13.96 1.31 20 0 c 8.41 -1.83 17.84 -6.29 26 -10 l 7 -5 "/></svg>
/*try {
convertToPng(sb.toString(), "e:/hr.png");
} catch (Exception e) {
e.printStackTrace();
}*/
String s="=\\\"=";
System.out.println(s.indexOf("/"));
s=s.replaceAll("\\", "*");
System.out.println(s);
}
}
jsp页面demo见附件
分享到:
相关推荐
签名完成后,可以使用提供的按钮将签名保存为Base64字符串,或者清除当前的签名。 在实际应用中,开发者可能会进一步扩展这个Demo,例如添加保存签名的功能,将Base64数据发送到服务器,或者将签名数据与表单中的...
HTML签字加时间水印(支持移动端)-jSignature-扩展。根据jSignature官方demo,制作自己的带水印签字图片,图片格式只用了base64,喜欢的朋友可以自己改全格式的图片,欢迎大家指导
cmd-bat-批处理-脚本-IE主页修改.zip
Delphi 12.3控件之uniGUI-Extras_1.95.0.1600.rar
内容概要:本文主要介绍了SQL注入的概念、危害及其防范措施。SQL注入是攻击者通过恶意构造输入,使服务器执行非预期的SQL命令的一种攻击方式,常因用户输入未
使用方法:拷贝到Auto CAD的Fonts下
cmd-bat-批处理-脚本-维护版.zip
解压
内容概要:本文档为《mysql.docx》,主要汇总了MySQL的各类常用命令,分为基础命令、数据库相关命令、数据表相关命令和事务相关命令四大部分。基础命令涵盖了连接、创建、删除数据库,创建和删除表,插入、查询、更新、删除数据等基本操作;数据库相关命令则进一步细化了对数据库的管理操作,如修改编码格式、查看数据库详细信息等;数据表相关命令着重介绍了对表结构和数据的操作,包括创建、修改、删除表,添加、删除、修改列,创建和删除索引等;事务相关命令主要涉及事务的开始、提交、回滚,设置事务隔离级别,以及表的锁定与解锁操作。; 适合人群:适用于具有一定SQL基础,尤其是MySQL使用经验的数据库管理员或开发人员。; 使用场景及目标:①帮助用户快速查找并正确使用MySQL的各种命令;②提高用户对MySQL数据库的操作能力,包括但不限于数据库和表的创建、修改、删除,数据的增删改查等;③掌握MySQL事务处理机制,确保数据的一致性和完整性。; 其他说明:本文档是MySQL命令的集合,建议用户在实际操作前先熟悉各个命令的具体用法,并在测试环境中进行练习,避免误操作导致数据丢失或其他严重后果。
cmd-bat-批处理-脚本-交换两个变量的值而不使用临时变量.zip
内容概要:集成测试是确保软件质量的关键环节,它在单元测试基础上验证模块间的交互和协作。文章详细介绍了集成测试的目的、重要性、流程步骤、策略与方法以及常见问题的解决办法。集成测试不仅验证模块接口的正确性,还确保系统的整体功能和性能符合预期。文章通过一个电商系统的实际案例,展示了集成测试在发现和解决问题中的具体应用。最后,展望了集成测试未来的发展趋势,如自动化测试、云计算、大数据和人工智能技术的应用。 适合人群:软件开发人员、测试工程师、项目经理及相关技术人员。 使用场景及目标:①了解集成测试在整个软件开发生命周期中的作用和重要性;②掌握集成测试的详细流程,包括测试计划制定、环境搭建、用例设计、执行与记录、缺陷管理和回归测试、测试总结与报告;③学习集成测试的不同策略(自顶向下、自底向上、混合策略)和方法(黑盒测试、白盒测试、模拟测试),并理解其适用场景;④掌握常见问题(接口不匹配、数据传递错误、性能瓶颈)的解决办法。 其他说明:本文不仅提供了集成测试的理论知识,还结合实际案例进行详细讲解,帮助读者更好地理解和应用集成测试技术。未来集成测试将受益于自动化测试、云计算、大数据和人工智能技术的发展,测试人员应不断学习新技术,优化测试流程,提高软件质量和效率。
cmd脚本-bat批处理-快速设定分辨率.zip
内容概要:本文献为电子科技大学硕士学位论文,题目为“高阶过采样delta-sigma DAC设计”。论文首先介绍了DAC的基本概念及其多种结构,重点阐述了delta-sigma DAC的优势,包括实现24位以上量化精度、简化模拟部分设计等。接着详细探讨了delta-sigma DAC的核心组成部分——过采样和噪声整形。过采样部分采用8倍插值8倍采样保持结构,其中插值器由2倍和4倍插值器级联构成;噪声整形部分采用5阶结构,优化了零点和极点,形成前馈加局部振荡反馈的噪声整形环。论文还介绍了在Matlab中完成的数字模型和FPGA平台上实现的硬件设计,最终实现了16位数据位宽、信噪比为95.53dB的delta-sigma DAC。 适合人群:具备一定电子工程和数字信号处理基础,特别是对DAC设计感兴趣的研究生或研究人员。 使用场景及目标:①适用于研究高精度数模转换技术的学术机构;②为设计高阶过采样delta-sigma DAC提供理论和技术支持;③探索delta-sigma技术在音频和其他高精度应用领域的潜力。 阅读建议:此资源不仅涉及复杂的理论分析,还包括详细的硬件实现步骤,建议读者在理解基本概念的基础上逐步深入,结合Matlab仿真和FPGA实现进行实践,以加深对delta-sigma DAC设计的理解。
cmd-bat-批处理-脚本-弹出对话框.zip
提供一个ARIMA模型的MATLAB代码示例,该代码能够根据用户自身的具体需求灵活调整参数,从而达到预期的分析效果。
cmd-bat-批处理-脚本-倒记时(全屏).zip
ssm+vue图书管理系统全套源码+毕业论文+数据库sql,全套毕设,非常具有参考意义
cmd-bat-批处理-脚本-更改电源管理方式.zip
cmd-bat-批处理-脚本-禁止用XP的图片视频预览功能.zip