- 打开Typora安装目录:Typora\resources\app\app\window
- 备份frame.js后,在frame.js中搜索:
<!doctype html>\n<html${C}${t?" class='blink-to-pdf' ":""}>\n<head>\n<meta charset='UTF-8'><meta name='viewport' content='width=device-width initial-scale=1'>\n<title>${l}</title>${p}<style type='text/css'>html {overflow-x: initial !important;}${k}\n</style>${e.afterHeader||""}\n</head>\n<body class='${S.join(" ")}'>\n<div id='write' ${t?"style='top:auto'":""} class='${x}'>${a}</div>\n${d}${e.afterBody||""}</body>\n</html>
- 找到图示位置用以下代码替换:
- \n替换为以下代码(以下代码末尾的Test11111替换为你要添加的水印名):
-
\n<script type="text/javascript">const setWatermark = (str) => {const id = '1.23452384164.123412416';if (document.getElementById(id) !== null) document.body.removeChild(document.getElementById(id));const can = document.createElement('canvas');can.width = 200;can.height = 130;const cans = can.getContext('2d');cans.rotate((-20 * Math.PI) / 180);cans.font = '20pt Vedana';cans.fillStyle = 'rgba(200, 200, 200, 0.30)';cans.textBaseline = 'middle';cans.fillText(str, can.width / 10, can.height / 2);const div = document.createElement('div');div.id = id;div.style.pointerEvents = 'none';div.style.top = '0px';div.style.left = '0px';div.style.position = 'fixed';div.style.zIndex = '10000000';div.style.width = \`\${document.documentElement.clientWidth}px\`;div.style.height = \`\${document.documentElement.clientHeight * 1.9}px\`;div.style.background = \`url(\${can.toDataURL('image/png')}) left top repeat\`;document.body.appendChild(div);return id;};const watermark = {set: (str) => {let id = setWatermark(str);if (document.getElementById(id) === null) id = setWatermark(str);},del: () => {let id = '1.23452384164.123412416';if (document.getElementById(id) !== null) document.body.removeChild(document.getElementById(id));}};watermark.set('Test11111')</script>\n
- 重启Typora,打开你的文档导出PDF即可!
Typora(0.9.98(beta)版)导出pdf加水印
于 2023-11-16 13:47:31 首次发布