Examine the implementation of rect() in the Context2D prototype, likely in the source file (e.g., src/plugins/canvas.js). The current implementation creates an open subpath with six segments; it should create a closed subpath with four segments. Consult the HTML5 Canvas specification for the correct behavior and adjust the path commands accordingly. No linked PRs or assignees, so this issue is available for contribution.
Context2D does not implement rect() correctly · parallax/jsPDF#3409 | Good First Issue