siyuan-note/siyuan · error · Error
PDF rectangle annotation has invalid coordinates
Error message
PDF rectangle annotation has invalid coordinates
What it means
Guard in getRectImgData rejecting an annotation rectangle whose coordinates are not usable for capture (empty, inverted, or non-finite position values passed in the position array). The PDF rectangle annotation cannot be rendered to an image from such coordinates.
Source
Thrown at app/src/asset/anno.ts:1097
}, Constants.TIMEOUT_DBLCLICK);
};
async function getRectImgData(pdfObj: any, pageNumber: number, position: number[]) {
const pageView = pdfObj.pdfViewer.getPageView(pageNumber - 1);
if (!pageView) {
throw new Error(`PDF page view ${pageNumber} is unavailable`);
}
const pdfPage = await pdfObj.pdfDocument.getPage(pageNumber);
const totalRotation = ((pageView.rotation + pageView.pdfPageRotate) % 360 + 360) % 360;
const targetViewport = pdfPage.getViewport({
scale: PDF_RECT_CAPTURE_SCALE,
rotation: totalRotation,
});
const targetRect = targetViewport.convertToViewportRectangle(position);
const captureScale = getLimitedCaptureScale(targetRect);
if (captureScale <= 0) {
throw new Error("PDF rectangle annotation has invalid coordinates");
}
const viewport = pdfPage.getViewport({scale: captureScale, rotation: totalRotation});
const captureBounds = getCaptureCanvasBounds(viewport.convertToViewportRectangle(position));
const captureViewport = pdfPage.getViewport({
scale: captureScale,
rotation: totalRotation,
offsetX: -captureBounds.left,
offsetY: -captureBounds.top,
});
const captureCanvas = document.createElement("canvas");
captureCanvas.width = captureBounds.width;
captureCanvas.height = captureBounds.height;
const captureCtx = captureCanvas.getContext("2d");
if (!captureCtx) {
throw new Error("Unable to create a canvas context for the PDF rectangle annotation");
}View on GitHub (pinned to 8641553a1f)
Solutions
- Validate the selection rectangle has width and height greater than 0 before capture
- Clamp coordinates to the page viewport bounds
- Discard zero-area or inverted drag selections in the annotation UI
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at app/src/asset/anno.ts:1097 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/c59e93b551e06cd5.
Report an issue: GitHub.