牌位列印
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
<%@ Register Src="~/admin/_uc/alert.ascx" TagPrefix="uc1" TagName="alert" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="page_header" runat="Server">
|
||||
<style>
|
||||
.canvas-area{
|
||||
min-height: 100vw !important;
|
||||
}
|
||||
</style>
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
:host {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
--canvas-bg: #f8f9fa;
|
||||
--canvas-grid: #dee2e6;
|
||||
--paper-bg: #fffbf0;
|
||||
@@ -27,7 +27,7 @@
|
||||
background-image: linear-gradient(45deg, var(--canvas-grid) 25%, transparent 25%), linear-gradient(-45deg, var(--canvas-grid) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--canvas-grid) 75%), linear-gradient(-45deg, transparent 75%, var(--canvas-grid) 75%);
|
||||
background-size: 20px 20px;
|
||||
transition: background-color 0.3s;
|
||||
min-height: 100vw;
|
||||
/* min-height: 100vw;*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,32 @@
|
||||
<link href="~/admin/Templates/TBS5ADM001/css/Style.css" rel="stylesheet" />
|
||||
<link href="~/admin/item/css/floating.css" rel="stylesheet" />
|
||||
<link href="~/admin/item/css/tablet-design.css" rel="stylesheet" />
|
||||
<style>
|
||||
@media print {
|
||||
/*@page {
|
||||
size: 398mm 216mm portrait;
|
||||
margin: 0;
|
||||
}*/
|
||||
html, body, form, .full-home, #printArea, .canvas-area {
|
||||
height: auto !important;
|
||||
width: 210mm !important;
|
||||
overflow: visible !important; /*必須為 visible */
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
/* display: block !important;*/
|
||||
}
|
||||
.no-print, #customMenu {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div class="d-flex overflow-hidden" style="height:1920px">
|
||||
<div id="printArea" style="width: 100vw; height: 100vh">
|
||||
|
||||
<span class="btn btn-primary no-print" onclick="Printer.print()">列印</span>
|
||||
<div class="d-flex full-home" style="height: auto;width:100%;">
|
||||
<div id="printArea" class="printArea" style="width: auto; height: auto">
|
||||
|
||||
<%-- <div class="tablet-paper">
|
||||
</div>--%>
|
||||
@@ -28,7 +49,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div id="customMenu" style="display: none; position: absolute; background-color: #f9f9f9; border: 1px solid #ccc; padding: 10px; z-index: 1000;opacity:1;">
|
||||
<div id="customMenu" style="display: none; position: absolute; background-color: #f9f9f9; border: 1px solid #ccc; padding: 10px; z-index: 1000; opacity: 1;">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
@@ -58,6 +79,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form id="form1" runat="server">
|
||||
</form>
|
||||
</body>
|
||||
<script src="<%=ResolveUrl("~/js/bootstrap5/js/bootstrap.bundle.min.js")%>"></script>
|
||||
@@ -71,11 +93,11 @@
|
||||
<script src="<%=ResolveUrl("~/admin/item/jquery-ui/jquery-ui.min.js")%>"></script>
|
||||
<script>
|
||||
const Printer = {
|
||||
selected:null,
|
||||
selected: null,
|
||||
http_host: "",
|
||||
allStyle: [],
|
||||
allSize: [],
|
||||
allStyleDetails:[],
|
||||
allStyleDetails: [],
|
||||
printData: [],
|
||||
tabletElement: [],
|
||||
bg: [
|
||||
@@ -174,28 +196,32 @@
|
||||
},
|
||||
render() {
|
||||
let self = this;
|
||||
let canvas = $(` <div class="canvas-area flex-grow-1 overflow-auto d-flex flex-row align-items-center position-relative" ></div>`)
|
||||
this.printData.forEach(x => {
|
||||
|
||||
let style = this.allStyle.find(y => y.styleID == x.style);
|
||||
console.log("style:",style);
|
||||
console.log("style:", style);
|
||||
let size = this.allSize.find(y => y.paperID == style.paperSize);
|
||||
let canvas = $(` <div class="canvas-area flex-grow-1 overflow-auto d-flex flex-column align-items-center position-relative" ></div>`)
|
||||
|
||||
|
||||
let tabletpaper = $(` <div class="tablet-paper">
|
||||
</div>`)
|
||||
let img = self.bg.find(y=>y.name==style.backendImg);
|
||||
let img = self.bg.find(y => y.name == style.backendImg);
|
||||
tabletpaper.css({
|
||||
"background-color": "white",
|
||||
width: size.width + 'mm',
|
||||
height:size.height + 'mm',
|
||||
position: "absolute",
|
||||
|
||||
"background-image": `url(${img.path})`, 'background-size': '100% 100%',
|
||||
height: size.height + 'mm',
|
||||
position: "relative",
|
||||
"margin-bottom": "0",
|
||||
"background-image": `url(${img.path})`,
|
||||
'background-size': '100% 100%',
|
||||
"break-after": "page",
|
||||
"page-break-after": "always"
|
||||
});
|
||||
let tablet = JSON.parse(x.f_num_tablet);
|
||||
|
||||
let mid_items = tablet.mid_items;
|
||||
let left_items = tablet.left_items;
|
||||
console.log("mid_items:",mid_items)
|
||||
console.log("mid_items:", mid_items)
|
||||
let details = this.allStyleDetails.filter(y => y.styleID == x.style);
|
||||
let mid = [];
|
||||
mid_items.forEach(y => {
|
||||
@@ -204,7 +230,7 @@
|
||||
details.forEach(d => {
|
||||
if (d.isActive != "hidden") {
|
||||
console.log(d);
|
||||
let html="";
|
||||
let html = "";
|
||||
if (d.elementID = 'title1') {
|
||||
let $namelist = $(`<div class='nameList'></div>`).css({
|
||||
"writing-mode": "vertical rl",
|
||||
@@ -216,7 +242,7 @@
|
||||
height: `${d.height}px`,
|
||||
border: "0px solid #ccc",
|
||||
padding: "1px",
|
||||
"font-family": "BiauKai",
|
||||
"font-family": "Kaiti",
|
||||
"letter-spacing": "0.1em",
|
||||
"column-gap": "1px",
|
||||
"row-gap": "1px",
|
||||
@@ -230,7 +256,7 @@
|
||||
width: `${d.textWidth}px`,
|
||||
"text-align": "justify",
|
||||
"text-align-last": "justify",
|
||||
"margin-bottom": "40px",
|
||||
"margin-bottom": "20px",
|
||||
"margin-left": "5px",
|
||||
"text-justify": "inter-character",
|
||||
"z-index": 10000,
|
||||
@@ -252,6 +278,36 @@
|
||||
|
||||
})
|
||||
$(canvas).append(tabletpaper);
|
||||
console.log(size.width,size.height);
|
||||
let pageStyle = `<style id="pageStyle">
|
||||
|
||||
|
||||
@media print{
|
||||
:host {
|
||||
width:auto !important;
|
||||
height:auto !important;
|
||||
}
|
||||
@page {
|
||||
size:210mm 297mm !important;
|
||||
margin:0;
|
||||
}
|
||||
.tablet-paper {
|
||||
width: ${size.width}mm ;
|
||||
height: ${size.height}mm;
|
||||
position: relative !important;
|
||||
display: block !important;
|
||||
break-after: page !important;
|
||||
page-break-after: always !important;
|
||||
margin: 0 !important;
|
||||
border: none !important;
|
||||
}
|
||||
}
|
||||
`
|
||||
$("#pageStyle").remove();
|
||||
$("head").append(pageStyle
|
||||
);
|
||||
$(canvas).css("width", "210" + "mm");
|
||||
$(canvas).css("height","297"+ "mm");
|
||||
$("#printArea").append(canvas);
|
||||
//this.bindKeyEvent();
|
||||
});
|
||||
@@ -286,11 +342,11 @@
|
||||
console.log(fontSize, fontFamily, left, top);
|
||||
$("#customMenu").css({
|
||||
top: e.pageY + "px",
|
||||
left: (e.pageX+30) + "px"
|
||||
left: (e.pageX + 30) + "px"
|
||||
});
|
||||
left = left.replace("px", "");
|
||||
top = top.replace("px", "");
|
||||
$("#textX").val(self.fix2(left*0.265));
|
||||
$("#textX").val(self.fix2(left * 0.265));
|
||||
$("#textY").val(self.fix2(top * 0.265));
|
||||
$("#fontSize").val(fontSize);
|
||||
//$("#textWidth").val("");
|
||||
@@ -303,8 +359,8 @@
|
||||
},
|
||||
async changeLocation() {
|
||||
console.log(this.selected);
|
||||
$(this.selected).css("left", $("#textX").val()+"mm");
|
||||
$(this.selected).css("top", $("#textY").val()+"mm");
|
||||
$(this.selected).css("left", $("#textX").val() + "mm");
|
||||
$(this.selected).css("top", $("#textY").val() + "mm");
|
||||
},
|
||||
async changeSize() {
|
||||
$(this.selected).css("fontSize", $("#fontSize").val())
|
||||
@@ -317,16 +373,18 @@
|
||||
let spans = $(nameList).find("span");
|
||||
console.log(spans);
|
||||
if (spans) {
|
||||
spans.each(function(index,x) {
|
||||
$(x).css("width",$("#textWidth").val())
|
||||
spans.each(function (index, x) {
|
||||
$(x).css("width", $("#textWidth").val())
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
print() {
|
||||
//let s = this.allStyle.find(x => x.styleID == this.styleID)
|
||||
let size = this.allSize.find(x => x.paperID = "0001")
|
||||
|
||||
//setTimeout(() => { window.print(); }, 1000);
|
||||
let s = this.allStyle.find(x => x.styleID == this.styleID)
|
||||
let size = this.allSize.find(x => x.paperID = "20260311160935")
|
||||
let w = window.open('', '_blank');
|
||||
if (!w) {
|
||||
alert("請允許瀏覽器開啟彈出式視窗!");
|
||||
@@ -353,6 +411,81 @@
|
||||
|
||||
|
||||
<style>
|
||||
/* 基礎變數與強制背景列印 */
|
||||
* {
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
color-adjust: exact !important;
|
||||
}
|
||||
|
||||
/* 螢幕預覽樣式 */
|
||||
@media screen {
|
||||
body {
|
||||
background-color: #525659;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 20px 0;
|
||||
}
|
||||
#printArea {
|
||||
width: auto !important;
|
||||
height: auto !important; /* 移除 100vh 限制 */
|
||||
}
|
||||
.tablet-paper {
|
||||
margin-bottom: 30px;
|
||||
box-shadow: 0 0 10px rgba(0,0,0,0.5);
|
||||
background-color: white;
|
||||
}
|
||||
}
|
||||
|
||||
/* 關鍵:修正 Ctrl+P 空白問題 */
|
||||
@media print {
|
||||
@page {
|
||||
size: 210mm 272mm portrait;
|
||||
margin: 0;
|
||||
}
|
||||
html, body, form, .full-home, #printArea, .canvas-area {
|
||||
height: auto !important;
|
||||
width: auto !important;
|
||||
overflow: visible !important; /* 必須為 visible */
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
display: block !important;
|
||||
}
|
||||
.canvas-area{
|
||||
display:flex !important;
|
||||
flex-direction: row !important;
|
||||
}
|
||||
.no-print, #customMenu {
|
||||
display: none !important;
|
||||
}
|
||||
.tablet-paper {
|
||||
position: relative !important;
|
||||
display: block !important;
|
||||
break-after: page !important;
|
||||
page-break-after: always !important;
|
||||
margin: 0 !important;
|
||||
border: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* 元素排版樣式 */
|
||||
.tablet-paper {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100% 100%;
|
||||
}
|
||||
.tablet-element {
|
||||
position: absolute !important;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.vertical-text {
|
||||
writing-mode: vertical-rl !important;
|
||||
-webkit-writing-mode: vertical-rl !important;
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
|
||||
/* 名單金字塔佈局容器 */
|
||||
.roster-container {
|
||||
@@ -418,7 +551,7 @@
|
||||
.tablet-element {
|
||||
position: absolute !important; /* 絕對不能被 Bootstrap 覆蓋為 static */
|
||||
color: black !important; /* 確保文字是黑色的 */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.ancestor-wrapper {
|
||||
@@ -429,41 +562,22 @@
|
||||
align-items: center; /* 水平置中 */
|
||||
justify-content: center;
|
||||
width: fit-content;
|
||||
}
|
||||
}
|
||||
|
||||
.main-name {
|
||||
.main-name {
|
||||
line-height: 1.2;
|
||||
/* 保持大字 */
|
||||
}
|
||||
}
|
||||
|
||||
.sub-text {
|
||||
.sub-text {
|
||||
font-size: 0.6em; /* 縮小字體 */
|
||||
line-height: 1.2;
|
||||
margin-top: 4px; /* 與上方林張的間距 */
|
||||
white-space: nowrap; /* 避免自動換行 */
|
||||
writing-mode:vertical-rl
|
||||
}
|
||||
}
|
||||
|
||||
/* 列印時的紙張大小與頁面歸零 */
|
||||
@media print {
|
||||
@page {
|
||||
/* 動態套用您設定的紙張寬高 */
|
||||
size: ${size.width}mm ${size.height}mm portrait;
|
||||
margin: 0;
|
||||
}
|
||||
body, html {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
|
||||
}
|
||||
body{
|
||||
--page-w: ${size.width}mm;
|
||||
--page-h: ${size.height}mm;
|
||||
--font-max: 22pt;
|
||||
--bg-padding: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
${canvasHtml}
|
||||
|
||||
Reference in New Issue
Block a user