HWPJS를 사용하여 첫 번째 HWP 파일을 파싱해보세요.
먼저 패키지를 설치합니다.
npm install @ohah/hwpjs가장 간단한 사용 예제입니다.
import { readFileSync } from 'fs';
import { toJson } from '@ohah/hwpjs';
// HWP 파일을 읽어서 JSON으로 변환
const fileBuffer = readFileSync('./document.hwp');
const data = new Uint8Array(fileBuffer);
const result = toJson(data);
console.log(result);더 자세한 예제는 예제 페이지를 참고하세요.
import { readFileSync } from 'fs';
import { toJson } from '@ohah/hwpjs';
// HWP 파일을 JSON으로 변환
const fileBuffer = readFileSync('./document.hwp');
const data = new Uint8Array(fileBuffer);
const result1 = toJson(data);
// 에러 처리
try {
const result2 = toJson(data);
console.log('변환 성공:', result2);
} catch (error) {
console.error('변환 실패:', error);
}명령줄에서 직접 사용하려면 CLI 가이드를 참고하세요.
# 전역 설치
npm install -g @ohah/hwpjs
# 사용 예제
hwpjs to-json document.hwp -o output.json
hwpjs to-markdown document.hwp -o output.md