printWatermark.js
2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* 从idocv获取到pdf然后调取 pdf生成水印服务 再预览生成后的pdf
*
*/
var origFilePath='';//原pdf绝对路径
var outFilePath='';//打完水印pdf据对路径
//判段idocv上是否已经存在pdf
function checkIdocvPDF(pdfPath){
$.ajax({
type : "get",
url : CONF_DOC_UPLOADSERVERURL+pdfPath,
async: false,
success : function(data){
if(data.srcUrl){
origFilePath="D:/idocv"+data.srcUrl;
}else{
console.log("文件idocv中未找到!")
}
outFilePath=Date.now()+".pdf";
// createPdf(pdfPath,"D:/FTP/temp/"+printPath,printPath); "http://10.6.144.133/file/"+
}
})
}
/*//旧添加文字水印方法
* function (pdfPath,outfPath,watermark){
$.showLoading();
checkIdocvPDF(pdfPath);
outFilePath=outfPath?outfPath:outFilePath;
var result;
$.ajax({
url: CONF_DOC_CREATEWATERMARKPDF,
data: { filePath: origFilePath, watermarkText: watermark, outputFilePath: "D:/FTP/temp/"+outFilePath },
type: 'post',
async: false,
success: function (data) {
result = data == "True" ? true : false;
console.log(data);
if (result == true){
$.hideLoading();
result=CONF_DOC_FILEADDRESURL+"/temp/"+outFilePath;
// viewWatermarkPdf(result);
}
},
error:function(error,err,msg){
console.log(error);
$.hideLoading();
}
});
return result;
}
*/
//预览 该方法未用
function viewWatermarkPdf(path){
window.open(CONF_DOC_VIEWSERVERURL+path);
}
//二维码水印
createWatermarkPdf=function pdfQRCWatermark(data){
data =JSON.stringify(data);
var path='';
$.ajax({
type:"post",
url:CONF_DOC_SERVERURL+"mvc/watermark/pdfWatermark.do",
data:data,
contentType:'application/json;charset=utf-8',
async: false,
beforeSend:function (xhr){
$.showLoading();
},
complete:function (xhr){
$.hideLoading();
},
success: function (result) {
var newPath=result.message;
path=newPath!=undefined && newPath !=''?newPath:'';
// viewWatermarkPdf(CONF_DOC_FILEADDRESURL+path);
},
error:function(error,err,msg){
console.log(error);
}
})
return path;
}