Skip to content

Commit 07106f2

Browse files
jeremymanningclaude
andcommitted
Fix PDF checkbox rendering - use drawn rectangles instead of Unicode
Unicode checkbox characters (☑ ☐) are not supported by jsPDF's standard Times font, causing PDF corruption. Draw checkboxes as rectangles with X marks for checked items instead. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 336cf02 commit 07106f2

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

checklist.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,10 @@ function createPDF(dateValue) {
577577
doc.setFontSize(10);
578578
labels.forEach(function(label, index) {
579579
var isChecked = checkboxes[index] && checkboxes[index].checked;
580-
var checkSymbol = isChecked ? '\u2611' : '\u2610'; // ☑ or ☐
581580
var text = label.textContent.trim();
582581

583-
// Wrap text to content width
584-
var wrappedLines = doc.splitTextToSize(text, contentWidth - 8);
582+
// Wrap text to content width (leave room for checkbox)
583+
var wrappedLines = doc.splitTextToSize(text, contentWidth - 10);
585584

586585
// Check if we need a new page
587586
var itemHeight = wrappedLines.length * 4.5 + 3;
@@ -590,11 +589,22 @@ function createPDF(dateValue) {
590589
yPos = topMargin;
591590
}
592591

593-
// Draw checkbox symbol
594-
doc.setFont(mainFont, 'normal');
595-
doc.text(checkSymbol, leftMargin, yPos);
592+
// Draw checkbox as a rectangle (3mm x 3mm)
593+
var boxSize = 3;
594+
var boxY = yPos - 2.5; // Align with text baseline
595+
doc.setDrawColor(0);
596+
doc.setLineWidth(0.3);
597+
doc.rect(leftMargin, boxY, boxSize, boxSize);
598+
599+
// If checked, draw an X inside
600+
if (isChecked) {
601+
doc.setLineWidth(0.4);
602+
doc.line(leftMargin + 0.5, boxY + 0.5, leftMargin + boxSize - 0.5, boxY + boxSize - 0.5);
603+
doc.line(leftMargin + boxSize - 0.5, boxY + 0.5, leftMargin + 0.5, boxY + boxSize - 0.5);
604+
}
596605

597606
// Draw wrapped text with proper indentation
607+
doc.setFont(mainFont, 'normal');
598608
wrappedLines.forEach(function(line, lineIndex) {
599609
doc.text(line, leftMargin + 6, yPos + (lineIndex * 4.5));
600610
});

0 commit comments

Comments
 (0)