Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文件预览有添加打印功能的计划吗? #559

Open
itzixiao opened this issue May 15, 2024 · 0 comments
Open

文件预览有添加打印功能的计划吗? #559

itzixiao opened this issue May 15, 2024 · 0 comments

Comments

@itzixiao
Copy link

文件预览会添加打印功能吗?目前调用浏览器自带的打印功能会导致打印出边框和图标。
测试了下修改officePicture.ftl模板可以添加打印功能,目前只试了转成pdf预览的文件可以打印
`

<title>PDF图片预览</title> <#include "*/commonHeader.ftl"> <script src="js/lazyload.js"></script> <style> body { background-color: #404040; } .container { width: 100%; height: 100%; } .img-area { text-align: center; } .my-photo { max-width: 98%; margin:0 auto; border-radius:3px; box-shadow:rgba(0,0,0,0.15) 0 0 8px; background:#FBFBFB; border:1px solid #ddd; margin:1px auto; padding:5px; } @media print { @page { margin-top: 0px; margin-bottom: 0px; } .my-photo { border: none !important; /* 使用!important以确保覆盖其他可能存在的样式 */ box-shadow: none !important; /* 去除可能存在的阴影 */ outline: none !important; /* 去除可能存在的轮廓 */ width: 100% !important; } } </style>
打印 <#list imgUrls as img>
loading
<#if "false" == switchDisabled>

使用PDF预览

<script> window.onload = function () { /*初始化水印*/ initWaterMark(); checkImgs(); }; window.onscroll = throttle(checkImgs); function changePreviewType(previewType) { var url = window.location.href; if (url.indexOf("officePreviewType=image") !== -1) { url = url.replace("officePreviewType=image", "officePreviewType="+previewType); } else { url = url + "&officePreviewType="+previewType; } if ('allImages' === previewType) { window.open(url) } else { window.location.href = url; } }
function printPage(){
    const images = document.querySelectorAll('.my-photo');
    let html = '';
    images.forEach(image => {
        html += image.outerHTML;
    })
    printHtml(html)
}

function printHtml (html) {
    const bodyHtml = document.body.innerHTML;
    document.body.innerHTML = html;
    window.print();
    document.body.innerHTML = bodyHtml;
}
</script> `
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant