由于三方的報(bào)表軟件做報(bào)表不錯(cuò),可要做合同模板的有些功能實(shí)現(xiàn)不了关翎。故用前端畫(huà)html實(shí)現(xiàn)合同模板頁(yè)面负拟,一開(kāi)始合同模板編輯后打印,用的瀏覽器的打印功能脚仔,后續(xù)因?yàn)殡娮雍灳鸵肓巳絟tml轉(zhuǎn)pdf的工具wkhtmltopdf勤众。合同水印就需要同時(shí)兼容chrome瀏覽器打印和工具wkhtmltopdf轉(zhuǎn)pdf后打印的效果。
各方案比較
方案 | 支持動(dòng)態(tài)生成水印 | chrome瀏覽器打印 | wkhtmltopdf工具打印 |
---|---|---|---|
第一階段 | ? | ? | × |
第二階段 | × | ? | ? |
第三階段svg | ? | ? | × |
第三階段canvas | ? | ? | ? |
*個(gè)人推薦:如果你沒(méi)用wkhtmltopdf工具玻侥,選第三種决摧、第四種都行;用了wkhtmltopdf工具凑兰,選第四種掌桩。
注:wkhtmltopdf由于最后的版本是2000年左右,之后好像沒(méi)維護(hù)了姑食。它內(nèi)置的瀏覽器對(duì)es6及以上版本的js支持性比較差波岛,盡量別用,不然會(huì)出現(xiàn)各種狀況音半。
第一階段:js動(dòng)態(tài)添加多個(gè)文本標(biāo)簽
功能需求: 根據(jù)合同狀態(tài)(合同草稿则拷、已簽約、已備案等等)生成對(duì)應(yīng)的水印曹鸠。
大體實(shí)現(xiàn)思路:根據(jù)頁(yè)面的內(nèi)容的寬高煌茬,每個(gè)水印的大小來(lái)動(dòng)態(tài)生成一組水印標(biāo)簽,動(dòng)態(tài)遍歷添加到body里彻桃,通過(guò)樣式的positon:absolute坛善;控制每個(gè)水印標(biāo)簽位置。
代碼參考:代碼比較多邻眷,并且網(wǎng)上類(lèi)似思路的文章不少眠屎,給個(gè)類(lèi)似思路的參考鏈接:http://t.zoukankan.com/GongQi-p-4074609.html。
缺點(diǎn): 在兩種打印模式(chrome瀏覽器打印肆饶、工具wkhtmltopdf轉(zhuǎn)pdf打痈鸟谩)中,任何一個(gè)合同都會(huì)有強(qiáng)制分頁(yè)的情況(比如驯镊,合同封面葫督、附件的每個(gè)附件單獨(dú)提頁(yè)等等)竭鞍,而一旦出現(xiàn)強(qiáng)制分頁(yè)時(shí),無(wú)論怎么獲取合同頁(yè)面的寬高都無(wú)法做到和打印頁(yè)時(shí)一樣的總高候衍,導(dǎo)致最后幾個(gè)打印頁(yè)內(nèi)容無(wú)合同水印笼蛛,甚至水印重疊的問(wèn)題。
第二階段:純css實(shí)現(xiàn)蛉鹿,background-repeat: repeat;
實(shí)現(xiàn)多個(gè)水印
功能需求: 根據(jù)合同狀態(tài)(合同草稿滨砍、已簽約、已備案等等)生成對(duì)應(yīng)的水印妖异。(和第一階段一致)
大體實(shí)現(xiàn)思路: 將所有可能的合同狀態(tài)的水印枚舉出來(lái)(合同草稿惋戏、已備案、已簽約)他膳,然后讓ui按指定尺寸設(shè)計(jì)成圖片响逢,然后將圖片轉(zhuǎn)成對(duì)應(yīng)的base64碼值,添加到樣式里棕孙,用
background-repeat: repeat;
實(shí)現(xiàn)多個(gè)水印舔亭。代碼參考: 核心代碼如下:
/*水印*/
.watermark{
display: none;
position: fixed;
z-index: -1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-repeat: repeat;
background-position: 0 0;
background-size: 220px 220px;
}
/*合同草稿*/
.watermark.water-draft{
display: block;
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQBAMAAABykSv/AAA9EWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS41LWMwMTQgNzkuMTUxNDgxLCAyMDEzLzAzLzEzLTEyOjA5OjE1ICAgICAgICAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5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RmOlJERj4KPC94OnhtcG1ldGE+CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz5ljlyFAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAFVBMVEX////d3d35+fnz8/Pg4ODq6url5eW9fZpgAAAF10lEQVR42uzdvXacSBCG4XIjiPWpgRhZY8Vg2Y4F2uMY7F3H07I9938Je4ACGqwL2G+23kQcReBniubnaCyWZ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TYkyiI/qUFEYhPDiQKIpJygdTS7Em2+5C/qUBE9iROQcZNLhA5kCiIRgRyqnckG4hwgbjWKwk7CKAk7CDAnZKwg6CXiCTjBSn2J65ADCIxySMxSBWTuJoWxH3dkfCCnHCOSXhBWpQLCTkIVhJyEGwk5CDAs5Jwg0QkNTVIu03JMzOIP20kXniadjsGqZ2SBK4h0d0OK4gem74NpSPJVhA9tlpF+EhWEP2pM0JGksvDAqI/9axFSLIHIVxH1uFOAaBaQAb9ZDGSDAA6BUkVhJYkr2aQk4LwkrzopDQKQkuyfKRcUBBWkvUjlSgIMUktGjmJl33Ma0kc9VpC2Yf6SNILT9Uq8QX1gaQQntLzwtEqwEZCBTKcJ4TPATNDTPIPEwjyy+USMPcsMQlVA+JuZUdCBbLrTmISXpCyFlaSAVHfq+PdO08NtrxobCQqUvy4XL4/rV8JQjol9zrgiX4V28uepKY7kGb5brw6JvFcIhFICx+T1FwHEoMgJvFcZ627GAQxSS1cIjGIkmhsIjEI4FkP5DYC4SUZgNsYpGUlCcBzBFJkrCQt8DMC6SWQkgBoIxARUhIHYAcijpMkAbADYSVJ9yD6K0KSmyOI3jPmQta7t0HQES7sRXgDpCJc2H12BMlDx7ge3skRpMsqxmXkWY4glVAuI/0fIKT/pWHNDaK5hx/VEYT8lSE1iBYAeHaQ7TKRH0SckigIPckCQk+iIPwkCsJPoiDkJDEIPwk/yPGRA/9aciUknVwFic46P4mC0Od+KQh9TizLsizLsizLsizLsv5tDw4JAAAAGAb1b30z9QwAAAAAAAAAAAAAAAAAAAAAAAAA5A2WClcnPfKqLQAAAABJRU5ErkJggg==");
}
-
效果圖:
- 缺點(diǎn): 每新增一種合同狀態(tài),需要重新用新圖轉(zhuǎn)base64碼值蟀俊,還得改動(dòng)合同頁(yè)面html代碼钦铺。
第三階段:cavas(或svg)轉(zhuǎn)圖片的base64碼值,結(jié)合第二種階段的思路肢预。
功能需求: 在第二階段的基礎(chǔ)上矛洞,用戶提出要用合同編號(hào)做合同水印,每個(gè)業(yè)務(wù)件對(duì)應(yīng)的合同編號(hào)不一樣烫映,故需要?jiǎng)討B(tài)生成水印效果沼本,這會(huì)兒?jiǎn)涡形谋尽=Y(jié)果隔了一周左右锭沟,又一個(gè)地方的用戶提出需要顯示多行文本的水映檎住(城市名、平臺(tái)名稱族淮、合同編號(hào)郊丛、簽約時(shí)間)。
大體實(shí)現(xiàn)思路: 將canvas或svg轉(zhuǎn)base64碼值瞧筛,然后結(jié)合第二階段的思路。
svg實(shí)現(xiàn)方式
- 代碼參考: demo頁(yè)面代碼如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<title>svg動(dòng)態(tài)生成合同水印(轉(zhuǎn)pdf的工具生成的碼值不一樣导盅,故pdf沒(méi)法生成水印)</title>
<script src="jquery.js"></script>
<style type="text/css">
body{
font-family:-apple-system-font,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Hiragino Sans GB,Microsoft YaHei UI,Microsoft YaHei,Arial,sans-serif;
color: #000;
}
.water{
background-color: transparent;
background-repeat: repeat;
background-position: 0 0;
background-size: 220px 220px;
}
.svg-wrap{
width: 220px;
height: 220px;
border: 1px solid #f00;
}
.svgimg,
#detail{
margin-bottom: 20px;
width: 500px;
min-height: 240px;
/* background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGlkPSJteXN2ZyIgaGVpZ2h0PSIyMjAiIHdpZHRoPSIyMjAiIGVuY29kaW5nPSJ1dGYtOCI+CiAgICAgICAgICAgIDx0ZXh0IGZpbGw9IiNmMDAiIGZvbnQ9ImJvbGQg5a6L5L2TIiBmb250LXNpemU9IjMwIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBkb21pbmFudC1iYXNlbGluZT0ibWlkZGxlIiB0cmFuc2Zvcm09InJvdGF0ZSgtNDUsMTEwLDExMCkiIHg9IjExMCIgeT0iMTEwIiBlbmNvZGluZz0idXRmLTgiPuW3suWkh+ahiDwvdGV4dD4KICAgICAgICA8L3N2Zz4='); */
background-repeat: repeat;
background-position: 0 0;
background-size: 100px 100px;
word-break: break-all;
}
</style>
</head>
<body class="">
<!-- XT20220708151515 已備案-->
<!-- font="bold 宋體" -->
<h4>待轉(zhuǎn)換的svg:水印文本:XT20220708151515较幌、已備案</h4>
<div class="svg-wrap">
<svg id="mysvg" height="220" width="220" encoding="utf-8">
<text fill="#f00" font-size="30" text-anchor="middle" dominant-baseline="middle" transform="rotate(-45,110,110)" x="110" y="110" encoding="utf-8">已備案</text>
</svg>
</div>
<h4>svg轉(zhuǎn)換后的img的base64碼值和背景圖渲染效果:</h4>
<div class="svgimg" id="water"></div>
<div>
網(wǎng)頁(yè)版、wkhtmltopdf工具時(shí)白翻,生成的base64碼值是否一致:<span class="dev"></span>
</div>
<!-- https://www.bootcdn.cn/Base64/ -->
<!-- <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/Base64/1.1.0/base64.min.js"></script> -->
<script>
//初始化加載
$(function () {
//網(wǎng)頁(yè)版乍炉,生成的base64碼值
//已備案
var page64 = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGlkPSJteXN2ZyIgaGVpZ2h0PSIyMjAiIHdpZHRoPSIyMjAiIGVuY29kaW5nPSJ1dGYtOCI+CiAgICAgICAgCTx0ZXh0IGZpbGw9IiNmMDAiIGZvbnQtc2l6ZT0iMzAiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGRvbWluYW50LWJhc2VsaW5lPSJtaWRkbGUiIHRyYW5zZm9ybT0icm90YXRlKC00NSwxMTAsMTEwKSIgeD0iMTEwIiB5PSIxMTAiIGVuY29kaW5nPSJ1dGYtOCI+5bey5aSH5qGIPC90ZXh0PgogICAgICAgIDwvc3ZnPg==';
//XT20220708151515
// page64 = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGlkPSJteXN2ZyIgaGVpZ2h0PSIyMjAiIHdpZHRoPSIyMjAiIGVuY29kaW5nPSJ1dGYtOCI+CiAgICAgICAgCTx0ZXh0IGZpbGw9IiNmMDAiIGZvbnQtc2l6ZT0iMzAiIHRleHQtYW5jaG9yPSJtaWRkbGUiIGRvbWluYW50LWJhc2VsaW5lPSJtaWRkbGUiIHRyYW5zZm9ybT0icm90YXRlKC00NSwxMTAsMTEwKSIgeD0iMTEwIiB5PSIxMTAiIGVuY29kaW5nPSJ1dGYtOCI+WFQyMDIyMDcwODE1MTUxNTwvdGV4dD4KICAgICAgICA8L3N2Zz4=';
//wkhtmltopdf工具绢片,生成的base64碼值
var tool64 = 'data:image/svg+xml;base64,PHN2ZyBpZD0ibXlzdmciIGhlaWdodD0iMjIwIiB3aWR0aD0iMjIwIiBlbmNvZGluZz0idXRmLTgiPgogICAgICAgIAk8dGV4dCBmaWxsPSIjZjAwIiBmb250LXNpemU9IjMwIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBkb21pbmFudC1iYXNlbGluZT0ibWlkZGxlIiB0cmFuc2Zvcm09InJvdGF0ZSgtNDUsMTEwLDExMCkiIHg9IjExMCIgeT0iMTEwIiBlbmNvZGluZz0idXRmLTgiPuW3suWkh+ahiDwvdGV4dD4KICAgICAgICA8L3N2Zz4=';
function svgBase64() {
var svg = document.getElementById('mysvg');
var s = new XMLSerializer().serializeToString(svg);
// 方法一
s = unescape(encodeURIComponent(s));//btoa、atoa不支持中文岛琼,用unescape處理
var svgBase64 = window.btoa(s);
svgBase64 = window.decodeURIComponent(svgBase64);
// 方法二
// s = decodeURIComponent(encodeURIComponent(s));//unescape已經(jīng)過(guò)時(shí)廢棄底循,換成uri處理
// var svgBase64 = window.btoa(reEncode(s));
// svgBase64 = svgBase64;
// 方法三
// var svgBase64 = Base64.encode(s);//base64.min.js
var imgBase64 = 'data:image/svg+xml;base64,'+svgBase64;
console.log({code:imgBase64});
console.log(tool64);
$('.dev').html(imgBase64==page64?'是':'否');
var imgStr = "background-image: url('"+imgBase64+"');";
$('.svgimg').html(imgStr);
$('.svgimg').attr('style',imgStr);
}
function reEncode(data) {
return decodeURIComponent(
encodeURIComponent(data).replace(/%([0-9A-F]{2})/g, function(match, p1) {
const c = String.fromCharCode('0x'+p1);
return c === '%' ? '%25' : c;
})
)
}
svgBase64();
});
</script>
</body>
</html>
-效果圖:
-
缺點(diǎn): 雖然chrome瀏覽器打印能滿足,但是工具wkhtmltopdf轉(zhuǎn)pdf打印槐瑞,水印效果消失熙涤。問(wèn)題點(diǎn):網(wǎng)頁(yè)上svg轉(zhuǎn)base64的生成的碼值和工具wkhtmltopdf內(nèi)置瀏覽器生成的碼值不一致,并且后者生成的base64碼值單獨(dú)拿出來(lái)放瀏覽器的也無(wú)法顯示困檩,放console里祠挫,點(diǎn)擊后只能解析成svg,不能解析成圖片悼沿。如下圖:
canvas實(shí)現(xiàn)方式
- 代碼參考: demo頁(yè)面代碼如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<title>canvas動(dòng)態(tài)生成合同水印(多行文本)</title>
<script src="jquery.js"></script>
<style type="text/css">
body{
font-family:-apple-system-font,BlinkMacSystemFont,Helvetica Neue,PingFang SC,Hiragino Sans GB,Microsoft YaHei UI,Microsoft YaHei,Arial,sans-serif;
color: #000;
}
.red{
color: #f00;
padding-right: 6px;
}
/*水印*/
.watermark{
display: none;
position: fixed;
z-index: -1;
left: 0;
top: 0;
width: 100%;
/*height: 1134px;*/
height: 100%;
background-repeat: repeat;
background-position: 0 0;
background-size:300px 300px;
}
/*無(wú)水印*/
.watermark.water-no{
display: none !important;
}
/* 調(diào)試用 */
body{
padding: 10px;
padding-bottom: 100%;/*如果不加等舔,那么調(diào)試的哪些div全是absolute,fixed布局,會(huì)導(dǎo)致body本身并沒(méi)有撐開(kāi)高度糟趾,所以轉(zhuǎn)pdf后會(huì)看不到水印*/
}
.test-canvas{
position: absolute;
left: 430px;
top: 10px;
}
/* 計(jì)算用 */
.test-fli{
position: absolute;
left: 150px;
top: 150px;
}
.test-con{
position: absolute;
left: 10px;
top: 10px;
width: 400px;
height: 400px;
outline: 1px solid #f00;
}
.con1,
.con2,
.con3{
outline: 1px solid #0f0;
width: 278px;
height: 110px;
display: flex;
justify-content: center;
align-items: center;
}
.con1{
position: absolute;
left: 0;
top: 0;
}
.con2{
outline: 1px dashed #0f0;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
.con3{
outline: 1px dashed #00f;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%) rotate(-45deg);
}
</style>
<!-- <script src="download2.js"></script> -->
</head>
<body>
<!--水印-->
<div class="watermark"></div>
<div class="test-fli">
<div class="test-canvas" style="left: 10px;">
<canvas id="myCanvas" width="400" height="400" style="outline:1px solid #f00;"></canvas>
</div>
<!-- 對(duì)比參照用 -->
<div class="test-con">
<div class="con1">原位置(canvas畫(huà)布文字內(nèi)容的寬高)</div>
<div class="con2">居中</div>
<div class="con3" style="font-size: 20px;line-height: 30px;text-align: center;"></div>
</div>
</div>
<script>
//初始化加載
$(function () {
function canvasToBase64(text,opt){
//水印內(nèi)容
var txt = text;//多行文本慌植,用逗號(hào)(,)分割。
if(!text) return false;
var txtArr = txt.split(',');
if(!opt){
opt = {};
}
//水印配置:字體义郑,字號(hào)蝶柿,是否加粗,文本傾斜角度魔慷,文本顏色只锭,水印圖的寬高(必須大于文本寬高)
var fontSize = opt.fontSize || 20;//單位:px,單行文本的字號(hào)
var fontSizeArr = opt.fontSizeArr ? opt.fontSizeArr : [];//單位:px院尔,多行文本的字號(hào)
var lineHeight = opt.lineHeight ? opt.lineHeight : Math.floor(fontSize*1.5);//行高蜻展,默認(rèn)為fontSize字號(hào)的1.5倍行高
var fontFamily = opt.fontFamily || '宋體';//字體,默認(rèn)宋體
var fontWeight = opt.fontWeight || 'bold';//是否加粗邀摆,默認(rèn)加粗
var angle = opt.angle || -45;//文本傾斜角度纵顾,默認(rèn)-45deg
var fontColor = opt.fontColor || '#d9d9d9';//文本顏色,默認(rèn)'#d9d9d9'
var width = opt.width || 200;//畫(huà)布canvas寬度栋盹,單位px施逾,默認(rèn)200
var height = opt.height || 200;//畫(huà)布canvas高度,單位px例获,默認(rèn)200
var txtHeight = lineHeight*(txtArr.length)- (lineHeight-fontSize);//文字高度汉额,因?yàn)槲淖执怪狈较蚴莟op,高度需要減掉最后一行文本的多余行間距:lineHeight-fontSize
// var canvas = document.getElementById("myCanvas");//本地調(diào)試效果用
var canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
var context = canvas.getContext("2d");
// 設(shè)置字體
context.font = fontWeight+' '+fontSize+'px '+fontFamily;//比如:"bold 20px 宋體"
// 設(shè)置水平對(duì)齊方式
context.textAlign = 'left';//left,center,right
// 設(shè)置垂直對(duì)齊方式
context.textBaseline = 'top';//top,bottom,middle
//不旋轉(zhuǎn)榨汤,參考用
// var angle = -45;
var strWidth = context.measureText(txt).width;
var strWidthArr = [];
txtArr.forEach(function(txt, index){
var tempW = Math.ceil(context.measureText(txt).width);//向上取整蠕搜,保證無(wú)小數(shù)
strWidthArr.push(tempW);
});
console.log('文字塊:',strWidthArr);
strWidth = Math.max.apply(null,strWidthArr);
console.log("文字塊寬高:"+strWidth+','+txtHeight);
context.save();
var tx = (canvas.width - strWidth)/2;
var ty = (canvas.height - txtHeight)/2;//字號(hào)等于行高
//中心位置旋轉(zhuǎn)
context.save();
//p0 畫(huà)布起始點(diǎn)(0,0),p1 canvas畫(huà)布中心點(diǎn)(canvas.width/2, canvas.height/2)收壕,p2 文本塊最終位置的左上角那個(gè)店(x2,y2)未知的需計(jì)算
var p1p2 = Math.sqrt(Math.pow(strWidth/2,2)+Math.pow(txtHeight/2,2));//文本塊左上角妓灌,中心點(diǎn)連線長(zhǎng)度
var p1p2Angle = (Math.atan(strWidth/txtHeight)*180/Math.PI-(90-Math.abs(angle)))*Math.PI/180;//文本塊左上角轨蛤,中心點(diǎn)連線和水平軸x的角度
console.log('文本塊left-center連線: length:'+p1p2+',angle(PI):'+p1p2Angle);
tx = (canvas.width/2)-Math.cos(p1p2Angle)*p1p2;
ty = (canvas.height/2)+Math.sin(p1p2Angle)*p1p2;
console.log('p2:('+tx+','+ty+')');
// ty = 334;
context.translate(tx, ty);
context.rotate(angle * Math.PI / 180);//先移動(dòng)translate,再旋轉(zhuǎn)rotate,就是以文本原點(diǎn)為基點(diǎn)虫埂,如果先旋轉(zhuǎn)再移動(dòng)祥山,就是以畫(huà)布canvas原點(diǎn)為基點(diǎn)
context.fillStyle = fontColor;
var y = 0;
var x = 0;
txtArr.forEach(function(txt, index){
if(fontSizeArr.length==txtArr.length){
//如果每行文本的字號(hào)不一樣
var tempFontSize = fontSizeArr[index];
context.font = fontWeight+' '+tempFontSize+'px '+fontFamily;//比如:"bold 20px 宋體"
}
x = (strWidth - strWidthArr[index])/2;
context.fillText(txt, x, y + lineHeight * index);
});
// context.fillText(txt, 0, 0);//單行文字
context.restore();
// 生成圖片信息
var dataUrl = canvas.toDataURL('image/png');
return dataUrl;
}
// var photoUrl = canvasToBase64('存量房網(wǎng)上交易平臺(tái),合同編號(hào):預(yù)201911260001,2022/10/13 11:01:02');
//調(diào)試文本:合同草稿,XT20220708151515
//多行文本:逗號(hào)(,)分割掉伏,比如:'存量房網(wǎng)上交易平臺(tái),合同編號(hào):預(yù)201911260001,2022/10/13 11:01:02'
var photoUrl = canvasToBase64('阜陽(yáng)市,新建商品房交易網(wǎng)上交易平臺(tái),合同編號(hào):FY2022335646,2022/10/13 11:01:02',{
width: 400,
height: 400,
fontSize: 20,
// angle: -30,
// fontSizeArr: [18,20,18],//多行文本缝呕,每行文字字號(hào)不一樣時(shí)配置
// lineHeight: 30,//默認(rèn)為字號(hào)的1.5倍行高
// fontColor: '#f00',
});
// console.log('文字轉(zhuǎn)圖片:',photoUrl);
$('.watermark').attr('style','display:block;background-image:url('+photoUrl+');background-size:400px 400px');
});
</script>
</body>
</html>
-
效果圖:
缺點(diǎn): 暫無(wú)战惊。