找回密码
 立即注册

QQ登录

只需一步,快速开始

server2021

高级会员

30

主题

144

帖子

1018

积分

高级会员

积分
1018
server2021
高级会员   /  发表于:2024-2-18 10:00  /   查看:547  /  回复:2
1金币
  1. //warning =document.getElementById("r15c55p");
  2. var warning = document.createElement("img");


  3. warning.src = "http://localhost:25708/Forguncy/GeneratedResources/Images/GenerateImages/ImageCellType/xxx.png";
  4. //warning.id = "watermark";
  5. //warning.style.fontSize="24px";
  6. //warning.style.color="red";

  7. warning.style.transform="rotate(-45deg)";
  8. warning.style.position="absolute";
  9. warning.style.width="147.5px";
  10. warning.style.height="97.3px";



  11. const box=document.getElementById('r21c43p');// 获取元素
  12. const ct = box.getBoundingClientRect().top - 50; // 元素上边距离页面可视区上边的距离
  13. const rl = box.getBoundingClientRect().right;// 元素左边距离页面可视区左边的距离
  14. console.log(`Element's top position relative to the document: ${ct}px`);
  15. console.log(`Element's left position relative to the document: ${rl}px`);




  16. warning.style.top=ct+"px";
  17. //warning.style.left=rl + "px";
  18. warning.style.left="810px";
  19. //warning.style.border="5px solid red";
  20. //warning.style.padding="10px";
  21. //document.body.appendChild(warning);
  22. document.getElementById("fgc-popup-dialog").appendChild(warning);
复制代码
按照这段代码,基本实现了想要的效果,但是打印(采用“打印/导出页面到PDF”)时,发现加的图片章是没有的,不知何故。是偏移位置变化的原因吗?如果是,如何确保不会偏移。



最佳答案

查看完整内容

这边看大佬的问题已经在之前的帖子中使用插入图片的方式解决了,这边就不再过多探讨了哈,毕竟活字格中,能自己实现的功能,最号就不写代码

2 个回复

倒序浏览
最佳答案
最佳答案
Nathan.guo活字格认证 Wyn认证
超级版主   /  发表于:2024-2-18 10:00:49
来自 3#

这边看大佬的问题已经在之前的帖子中使用插入图片的方式解决了,这边就不再过多探讨了哈,毕竟活字格中,能自己实现的功能,最号就不写代码
回复 使用道具 举报
server2021
高级会员   /  发表于:2024-2-18 10:01:36
2#
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部