java实现给pdf文件添加水印效果
1.导入jar包
链接:https://pan.baidu.com/s/1yf7HYIxTrCuPGnkL9fjKmw 提取码:8jd0
2.开始吧
//处理pdf文件
public void loadPdf(HttpServletRequest request,HttpServletResponse response, String strUrl) throws Exception {
URL url = new URL(strUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//得到输入流
InputStream inputStream = conn.getInputStream();
String[] urlSplit = strUrl.split("/");
int i = urlSplit.length;
String[] nextSplit = urlSplit[i - 1].split("\\.");
//解析出名字
String fileName = nextSplit[0];
//来使得唯一
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
String str = sdf.format(System.currentTimeMillis());
for (int m = 1; m < 3; m++) {
int rd = (int) (Math.random() * 10);
str = str + rd;
}
//保存路径
String filePath = "D:\\" + fileName + "-" + str + ".pdf";
File file

最低0.47元/天 解锁文章
3975

被折叠的 条评论
为什么被折叠?



