@clazic/kordoc 2.5.2 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -154,7 +154,7 @@ interface OutlineItem {
154
154
  pageNumber?: number;
155
155
  }
156
156
  /** 구조화된 에러 코드 — 프로그래밍적 에러 핸들링용 */
157
- type ErrorCode = "EMPTY_INPUT" | "UNSUPPORTED_FORMAT" | "ENCRYPTED" | "DRM_PROTECTED" | "CORRUPTED" | "DECOMPRESSION_BOMB" | "ZIP_BOMB" | "IMAGE_BASED_PDF" | "NO_SECTIONS" | "PARSE_ERROR" | "FILE_TOO_LARGE";
157
+ type ErrorCode = "EMPTY_INPUT" | "UNSUPPORTED_FORMAT" | "ENCRYPTED" | "DRM_PROTECTED" | "CORRUPTED" | "DECOMPRESSION_BOMB" | "ZIP_BOMB" | "IMAGE_BASED_PDF" | "NO_SECTIONS" | "PARSE_ERROR" | "FILE_TOO_LARGE" | "CONVERT_FAILED" | "TIMEOUT" | "SOFFICE_NOT_FOUND" | "UNSUPPORTED_PLATFORM";
158
158
  type FileType = "hwpx" | "hwp" | "pdf" | "xlsx" | "docx" | "image" | "unknown";
159
159
  interface ParseResultBase {
160
160
  fileType: FileType;
@@ -251,6 +251,43 @@ interface WatchOptions {
251
251
  pages?: string;
252
252
  silent?: boolean;
253
253
  }
254
+ /** HWP/HWPX → PDF 변환 옵션 */
255
+ interface ConvertToPdfOptions {
256
+ /** 페이지 범위 ("1-3,5,7-10") — LibreOffice 필터가 지원하는 경우 */
257
+ pages?: string;
258
+ /** 품질/압축 설정 (미래 확장) */
259
+ quality?: "low" | "medium" | "high";
260
+ /** 타임아웃 (ms, 기본 60000) */
261
+ timeoutMs?: number;
262
+ /** 진행 상황 콜백 */
263
+ onProgress?: (percent: number, stage: string) => void;
264
+ /** LibreOffice 자동 설치 허용 (기본 true) */
265
+ autoInstallLibreOffice?: boolean;
266
+ /** LibreOffice 바이너리 직접 지정 */
267
+ sofficePath?: string;
268
+ }
269
+ /** PDF 변환 성공 결과 */
270
+ interface ConvertToPdfSuccess {
271
+ success: true;
272
+ /** PDF 바이너리 */
273
+ pdf: Uint8Array;
274
+ /** 원본 파일 형식 */
275
+ sourceFormat: "hwp" | "hwpx";
276
+ /** 페이지 수 (확인 가능한 경우) */
277
+ pageCount?: number;
278
+ }
279
+ /** PDF 변환 실패 결과 */
280
+ interface ConvertToPdfFailure {
281
+ success: false;
282
+ /** 에러 코드 */
283
+ code: ErrorCode;
284
+ /** 상세 에러 메시지 */
285
+ error: string;
286
+ /** 실패한 단계 */
287
+ stage?: "detect" | "validate" | "convert";
288
+ }
289
+ /** PDF 변환 결과 (discriminated union) */
290
+ type ConvertToPdfResult = ConvertToPdfSuccess | ConvertToPdfFailure;
254
291
 
255
292
  /** 문서 비교 엔진 — IR 레벨 블록 비교로 신구대조표 생성 */
256
293
 
@@ -306,6 +343,38 @@ interface MarkdownToXlsxOptions {
306
343
  */
307
344
  declare function markdownToXlsx(markdown: string, options?: MarkdownToXlsxOptions): Promise<ArrayBuffer>;
308
345
 
346
+ /**
347
+ * HWP/HWPX 파일을 PDF로 변환.
348
+ *
349
+ * @param input 파일 경로, Buffer, 또는 ArrayBuffer
350
+ * @param options 변환 옵션
351
+ * @returns 변환 결과 (성공/실패 discriminated union)
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * import { convertToPdf } from "kordoc"
356
+ * const result = await convertToPdf("document.hwp")
357
+ * if (result.success) {
358
+ * await writeFile("output.pdf", result.pdf)
359
+ * }
360
+ * ```
361
+ */
362
+ declare function convertToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
363
+ /**
364
+ * HWP 5.x 파일을 PDF로 변환 (포맷 감지 생략).
365
+ * 내부적으로 convertToPdf와 동일하지만 강제로 "hwp"로 처리.
366
+ *
367
+ * @deprecated convertToPdf()에 Buffer를 직접 전달하는 것과 동일
368
+ */
369
+ declare function convertHwpToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
370
+ /**
371
+ * HWPX 파일을 PDF로 변환 (포맷 감지 생략).
372
+ * 내부적으로 convertToPdf와 동일하지만 강제로 "hwpx"로 처리.
373
+ *
374
+ * @deprecated convertToPdf()에 Buffer를 직접 전달하는 것과 동일
375
+ */
376
+ declare function convertHwpxToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
377
+
309
378
  /** 매직 바이트 기반 파일 포맷 감지 */
310
379
 
311
380
  /** ZIP 파일 여부: PK\x03\x04 */
@@ -477,4 +546,4 @@ declare function parseXlsx(buffer: ArrayBuffer, options?: ParseOptions, zip?: JS
477
546
  /** DOCX 파일을 Markdown으로 변환 */
478
547
  declare function parseDocx(buffer: ArrayBuffer, options?: ParseOptions, zip?: JSZip): Promise<ParseResult>;
479
548
 
480
- export { type AcquireResult, AllKeysCoolingDownError, type ApiKeyRotationOptions, ApiKeyRotationPool, type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type ExtractedImage, type FileType, type FormField, type FormResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type KeyHealthSnapshot, type MarkdownToXlsxOptions, type OcrMode, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type StructuredOcrResult, type UnifiedOcrOptions, type UnifiedOcrProgressEvent, type UnifiedOcrResult, type UnifiedStage, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, detectFormat, detectZipFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToXlsx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx, runUnifiedOcrPipeline };
549
+ export { type AcquireResult, AllKeysCoolingDownError, type ApiKeyRotationOptions, ApiKeyRotationPool, type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type ConvertToPdfFailure, type ConvertToPdfOptions, type ConvertToPdfResult, type ConvertToPdfSuccess, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type ExtractedImage, type FileType, type FormField, type FormResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type KeyHealthSnapshot, type MarkdownToXlsxOptions, type OcrMode, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type StructuredOcrResult, type UnifiedOcrOptions, type UnifiedOcrProgressEvent, type UnifiedOcrResult, type UnifiedStage, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, convertHwpToPdf, convertHwpxToPdf, convertToPdf, detectFormat, detectZipFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToXlsx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx, runUnifiedOcrPipeline };
package/dist/index.d.ts CHANGED
@@ -154,7 +154,7 @@ interface OutlineItem {
154
154
  pageNumber?: number;
155
155
  }
156
156
  /** 구조화된 에러 코드 — 프로그래밍적 에러 핸들링용 */
157
- type ErrorCode = "EMPTY_INPUT" | "UNSUPPORTED_FORMAT" | "ENCRYPTED" | "DRM_PROTECTED" | "CORRUPTED" | "DECOMPRESSION_BOMB" | "ZIP_BOMB" | "IMAGE_BASED_PDF" | "NO_SECTIONS" | "PARSE_ERROR" | "FILE_TOO_LARGE";
157
+ type ErrorCode = "EMPTY_INPUT" | "UNSUPPORTED_FORMAT" | "ENCRYPTED" | "DRM_PROTECTED" | "CORRUPTED" | "DECOMPRESSION_BOMB" | "ZIP_BOMB" | "IMAGE_BASED_PDF" | "NO_SECTIONS" | "PARSE_ERROR" | "FILE_TOO_LARGE" | "CONVERT_FAILED" | "TIMEOUT" | "SOFFICE_NOT_FOUND" | "UNSUPPORTED_PLATFORM";
158
158
  type FileType = "hwpx" | "hwp" | "pdf" | "xlsx" | "docx" | "image" | "unknown";
159
159
  interface ParseResultBase {
160
160
  fileType: FileType;
@@ -251,6 +251,43 @@ interface WatchOptions {
251
251
  pages?: string;
252
252
  silent?: boolean;
253
253
  }
254
+ /** HWP/HWPX → PDF 변환 옵션 */
255
+ interface ConvertToPdfOptions {
256
+ /** 페이지 범위 ("1-3,5,7-10") — LibreOffice 필터가 지원하는 경우 */
257
+ pages?: string;
258
+ /** 품질/압축 설정 (미래 확장) */
259
+ quality?: "low" | "medium" | "high";
260
+ /** 타임아웃 (ms, 기본 60000) */
261
+ timeoutMs?: number;
262
+ /** 진행 상황 콜백 */
263
+ onProgress?: (percent: number, stage: string) => void;
264
+ /** LibreOffice 자동 설치 허용 (기본 true) */
265
+ autoInstallLibreOffice?: boolean;
266
+ /** LibreOffice 바이너리 직접 지정 */
267
+ sofficePath?: string;
268
+ }
269
+ /** PDF 변환 성공 결과 */
270
+ interface ConvertToPdfSuccess {
271
+ success: true;
272
+ /** PDF 바이너리 */
273
+ pdf: Uint8Array;
274
+ /** 원본 파일 형식 */
275
+ sourceFormat: "hwp" | "hwpx";
276
+ /** 페이지 수 (확인 가능한 경우) */
277
+ pageCount?: number;
278
+ }
279
+ /** PDF 변환 실패 결과 */
280
+ interface ConvertToPdfFailure {
281
+ success: false;
282
+ /** 에러 코드 */
283
+ code: ErrorCode;
284
+ /** 상세 에러 메시지 */
285
+ error: string;
286
+ /** 실패한 단계 */
287
+ stage?: "detect" | "validate" | "convert";
288
+ }
289
+ /** PDF 변환 결과 (discriminated union) */
290
+ type ConvertToPdfResult = ConvertToPdfSuccess | ConvertToPdfFailure;
254
291
 
255
292
  /** 문서 비교 엔진 — IR 레벨 블록 비교로 신구대조표 생성 */
256
293
 
@@ -306,6 +343,38 @@ interface MarkdownToXlsxOptions {
306
343
  */
307
344
  declare function markdownToXlsx(markdown: string, options?: MarkdownToXlsxOptions): Promise<ArrayBuffer>;
308
345
 
346
+ /**
347
+ * HWP/HWPX 파일을 PDF로 변환.
348
+ *
349
+ * @param input 파일 경로, Buffer, 또는 ArrayBuffer
350
+ * @param options 변환 옵션
351
+ * @returns 변환 결과 (성공/실패 discriminated union)
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * import { convertToPdf } from "kordoc"
356
+ * const result = await convertToPdf("document.hwp")
357
+ * if (result.success) {
358
+ * await writeFile("output.pdf", result.pdf)
359
+ * }
360
+ * ```
361
+ */
362
+ declare function convertToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
363
+ /**
364
+ * HWP 5.x 파일을 PDF로 변환 (포맷 감지 생략).
365
+ * 내부적으로 convertToPdf와 동일하지만 강제로 "hwp"로 처리.
366
+ *
367
+ * @deprecated convertToPdf()에 Buffer를 직접 전달하는 것과 동일
368
+ */
369
+ declare function convertHwpToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
370
+ /**
371
+ * HWPX 파일을 PDF로 변환 (포맷 감지 생략).
372
+ * 내부적으로 convertToPdf와 동일하지만 강제로 "hwpx"로 처리.
373
+ *
374
+ * @deprecated convertToPdf()에 Buffer를 직접 전달하는 것과 동일
375
+ */
376
+ declare function convertHwpxToPdf(input: string | ArrayBuffer | Buffer, options?: ConvertToPdfOptions): Promise<ConvertToPdfResult>;
377
+
309
378
  /** 매직 바이트 기반 파일 포맷 감지 */
310
379
 
311
380
  /** ZIP 파일 여부: PK\x03\x04 */
@@ -477,4 +546,4 @@ declare function parseXlsx(buffer: ArrayBuffer, options?: ParseOptions, zip?: JS
477
546
  /** DOCX 파일을 Markdown으로 변환 */
478
547
  declare function parseDocx(buffer: ArrayBuffer, options?: ParseOptions, zip?: JSZip): Promise<ParseResult>;
479
548
 
480
- export { type AcquireResult, AllKeysCoolingDownError, type ApiKeyRotationOptions, ApiKeyRotationPool, type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type ExtractedImage, type FileType, type FormField, type FormResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type KeyHealthSnapshot, type MarkdownToXlsxOptions, type OcrMode, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type StructuredOcrResult, type UnifiedOcrOptions, type UnifiedOcrProgressEvent, type UnifiedOcrResult, type UnifiedStage, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, detectFormat, detectZipFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToXlsx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx, runUnifiedOcrPipeline };
549
+ export { type AcquireResult, AllKeysCoolingDownError, type ApiKeyRotationOptions, ApiKeyRotationPool, type BlockDiff, type BoundingBox, type CellContext, type CellDiff, type ConvertToPdfFailure, type ConvertToPdfOptions, type ConvertToPdfResult, type ConvertToPdfSuccess, type DiffChangeType, type DiffResult, type DocumentMetadata, type ErrorCode, type ExtractedImage, type FileType, type FormField, type FormResult, type IRBlock, type IRBlockType, type IRCell, type IRTable, type ImageData, type InlineStyle, type KeyHealthSnapshot, type MarkdownToXlsxOptions, type OcrMode, type OcrProvider, type OutlineItem, type ParseFailure, type ParseOptions, type ParseResult, type ParseSuccess, type ParseWarning, type StructuredOcrResult, type UnifiedOcrOptions, type UnifiedOcrProgressEvent, type UnifiedOcrResult, type UnifiedStage, VERSION, type WarningCode, type WatchOptions, blocksToMarkdown, compare, convertHwpToPdf, convertHwpxToPdf, convertToPdf, detectFormat, detectZipFormat, diffBlocks, extractFormFields, isHwpxFile, isOldHwpFile, isPdfFile, isZipFile, markdownToHwpx, markdownToXlsx, parse, parseDocx, parseHwp, parseHwpx, parsePdf, parseXlsx, runUnifiedOcrPipeline };