Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cc20dec72
|
||
|
|
24f8475b10
|
@@ -244,28 +244,30 @@ async function generatePDF() {
|
|||||||
|
|
||||||
// Capture the sticker as an image
|
// Capture the sticker as an image
|
||||||
const canvas = await html2canvas(stickerElement, {
|
const canvas = await html2canvas(stickerElement, {
|
||||||
scale: 3,
|
scale: 4,
|
||||||
backgroundColor: '#ffffff',
|
backgroundColor: '#ffffff',
|
||||||
useCORS: true,
|
useCORS: true,
|
||||||
logging: false
|
logging: false
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create PDF with sticker dimensions
|
// Create PDF with A4 dimensions
|
||||||
const imgData = canvas.toDataURL('image/png');
|
const imgData = canvas.toDataURL('image/png');
|
||||||
|
|
||||||
const pdfWidth = 100; // mm
|
|
||||||
const pdfHeight = (canvas.height / canvas.width) * pdfWidth;
|
|
||||||
|
|
||||||
const pdf = new jsPDF({
|
const pdf = new jsPDF({
|
||||||
orientation: pdfHeight > pdfWidth ? 'portrait' : 'landscape',
|
orientation: 'portrait',
|
||||||
unit: 'mm',
|
unit: 'mm',
|
||||||
format: [pdfWidth + 10, pdfHeight + 10]
|
format: 'a4'
|
||||||
});
|
});
|
||||||
|
|
||||||
const x = 5;
|
// Sticker size on A4 (approximately 55mm wide)
|
||||||
const y = 5;
|
const stickerWidth = 55;
|
||||||
|
const stickerHeight = (canvas.height / canvas.width) * stickerWidth;
|
||||||
|
|
||||||
pdf.addImage(imgData, 'PNG', x, y, pdfWidth, pdfHeight);
|
// Position at top-left with small margin
|
||||||
|
const x = 10;
|
||||||
|
const y = 10;
|
||||||
|
|
||||||
|
pdf.addImage(imgData, 'PNG', x, y, stickerWidth, stickerHeight);
|
||||||
|
|
||||||
// Generate filename
|
// Generate filename
|
||||||
const regNumber = regNumberInput.value || 'sticker';
|
const regNumber = regNumberInput.value || 'sticker';
|
||||||
|
|||||||
+20
-21
@@ -1,7 +1,7 @@
|
|||||||
/* RS AUTO Template Styles */
|
/* RS AUTO Template Styles */
|
||||||
.sticker-rs-auto {
|
.sticker-rs-auto {
|
||||||
width: 280px;
|
width: 280px;
|
||||||
border: 3px solid #000;
|
border: 1px solid #000;
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
@@ -12,65 +12,64 @@
|
|||||||
background-color: #000;
|
background-color: #000;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 6px 8px;
|
padding: 4px 8px;
|
||||||
font-size: 18px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
letter-spacing: 4px;
|
letter-spacing: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sticker-rs-auto .sticker-barcode-row {
|
.sticker-rs-auto .sticker-barcode-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-bottom: 2px solid #000;
|
border-bottom: 1px solid #000;
|
||||||
padding: 4px 8px;
|
padding: 2px 0 2px 6px;
|
||||||
gap: 8px;
|
gap: 6px;
|
||||||
|
background: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sticker-rs-auto .sticker-barcode-row .barcode-number {
|
.sticker-rs-auto .sticker-barcode-row .barcode-number {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
font-weight: 500;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sticker-rs-auto .sticker-barcode-row .barcode {
|
.sticker-rs-auto .sticker-barcode-row .barcode {
|
||||||
height: 30px;
|
height: 24px;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sticker-rs-auto .sticker-body {
|
.sticker-rs-auto .sticker-body {
|
||||||
display: flex;
|
display: flex;
|
||||||
border-bottom: 2px solid #000;
|
border-bottom: 1px solid #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sticker-rs-auto .sticker-info {
|
.sticker-rs-auto .sticker-info {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 6px 8px;
|
padding: 4px 6px;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
line-height: 1.4;
|
line-height: 1.3;
|
||||||
|
border-right: 1px solid #000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sticker-rs-auto .sticker-info .date-row {
|
.sticker-rs-auto .sticker-info .date-row {
|
||||||
margin-bottom: 2px;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sticker-rs-auto .sticker-logo {
|
.sticker-rs-auto .sticker-logo {
|
||||||
width: 100px;
|
width: 85px;
|
||||||
border-left: 2px solid #000;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sticker-rs-auto .sticker-logo .logo-svg,
|
.sticker-rs-auto .sticker-logo .logo-svg,
|
||||||
.sticker-rs-auto .sticker-logo .logo-img {
|
.sticker-rs-auto .sticker-logo .logo-img {
|
||||||
width: 90px;
|
width: 100%;
|
||||||
height: 90px;
|
height: auto;
|
||||||
object-fit: contain;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sticker-rs-auto .sticker-footer {
|
.sticker-rs-auto .sticker-footer {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 4px 8px;
|
padding: 3px 8px;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
font-weight: 500;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<div>{{engineCapacity}}</div>
|
<div>{{engineCapacity}}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sticker-logo">
|
<div class="sticker-logo">
|
||||||
<img src="templates/rs-auto.svg" alt="RS AUTO" class="logo-img">
|
<img src="templates/rs-auto.png" alt="RS AUTO" class="logo-img">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sticker-footer">RS AUTO, TEL: 775 8999</div>
|
<div class="sticker-footer">RS AUTO, TEL: 775 8999</div>
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 97 KiB |
Reference in New Issue
Block a user