PDF 빈칸 감지
POST
/api/pdf/detect-blanks
Claude Vision을 사용하여 PDF 이미지에서 입력 가능한 빈칸(밑줄, 박 스 등)을 감지합니다.
요청
Body
interface DetectBlanksRequest {
image: string;
strip_index?: number;
total_strips?: number;
locale?: "ko" | "en";
}
| 필드 | 타입 | 필수 | 설명 |
|---|---|---|---|
image | string | ✅ | Base64 인코딩된 이미지 |
strip_index | number | 분할 이미지 인덱스 | |
total_strips | number | 전체 분할 수 | |
locale | string | 언어 설정 (기본: ko) |
예시
{
"image": "iVBORw0KGgoAAAANSUhEUgAA...",
"locale": "ko"
}
응답
성공 (200)
interface DetectBlanksResponse {
success: boolean;
blanks: DetectedBlank[];
table_detected: boolean;
confidence: number;
strip_index?: number;
}
interface DetectedBlank {
label: string;
x_percent: number;
y_percent: number;
width_percent: number;
height_percent: number;
field_type: "text" | "date" | "number" | "checkbox" | "signature" | "other";
is_required: boolean;
}
예시 응답
{
"success": true,
"blanks": [
{
"label": "성명",
"x_percent": 45,
"y_percent": 20,
"width_percent": 30,
"height_percent": 3,
"field_type": "text",
"is_required": true
},
{
"label": "생년월일",
"x_percent": 45,
"y_percent": 28,
"width_percent": 25,
"height_percent": 3,
"field_type": "date",
"is_required": true
}
],
"table_detected": false,
"confidence": 0.92
}
좌표 시스템
좌표는 이미지 기준 퍼센트(%)로 표현됩니다:
x_percent: 0 = 좌측, 100 = 우측y_percent: 0 = 상단, 100 = 하단width_percent: 빈칸 너비 비율height_percent: 빈칸 높이 비율
(0,0) ─────────────────── (100,0)
│ │
│ [x_percent, y_percent] │
│ ▼ │
│ ┌─────────┐ │
│ │ 빈칸 │ │
│ └─────────┘ │
│ │
(0,100) ───────────────── (100,100)
코드 예시
async function detectBlanks(pageImage: string) {
const response = await fetch("/api/pdf/detect-blanks", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
image: pageImage.replace(/^data:image\/\w+;base64,/, ""),
locale: "ko",
}),
});
const result = await response.json();
if (result.success) {
return result.blanks;
}
throw new Error("빈칸 감지 실패");
}
에러 응답
| 코드 | 설명 |
|---|---|
| 400 | 이미지 누락 |
| 500 | AI 처리 오류 |
{
"error": "No image provided"
}