|
5 | 5 | /// <reference types="node" /> |
6 | 6 |
|
7 | 7 | export class Parser { |
8 | | - /** |
9 | | - * Creates an instance of Parser for PDF processing |
10 | | - * @param pdf_file Path to the PDF file or Buffer containing PDF data |
11 | | - * @param password Optional password for encrypted PDF |
12 | | - */ |
13 | | - constructor(pdf_file: string | Buffer, password?: string); |
| 8 | + /** |
| 9 | + * Creates an instance of Parser for PDF processing |
| 10 | + * @param pdf_file Path to the PDF file or Buffer containing PDF data |
| 11 | + * @param password Optional password for encrypted PDF |
| 12 | + */ |
| 13 | + constructor(pdf_file: string | Buffer, password?: string); |
14 | 14 |
|
15 | | - /** |
16 | | - * Parse and convert PDF to DOCX |
17 | | - * @param docx_file Output DOCX file path |
18 | | - * @param options Conversion options |
19 | | - * @returns Promise resolving to parsing status |
20 | | - */ |
21 | | - parse(docx_file: string, options?: ConversionOptions): Promise<ParsingStatus>; |
| 15 | + /** |
| 16 | + * Parse and convert PDF to DOCX |
| 17 | + * @param docx_file Output DOCX file path |
| 18 | + * @param options Conversion options |
| 19 | + * @returns Promise resolving to parsing status |
| 20 | + */ |
| 21 | + parse(docx_file: string, options?: ConversionOptions): Promise<ParsingStatus>; |
22 | 22 |
|
23 | | - /** |
24 | | - * Convert a specific range of pages |
25 | | - * @param docx_file Output DOCX file path |
26 | | - * @param start_page Starting page number (1-based) |
27 | | - * @param end_page Ending page number (1-based) |
28 | | - * @param options Conversion options |
29 | | - * @returns Promise resolving to parsing status |
30 | | - */ |
31 | | - parsePages( |
32 | | - docx_file: string, |
33 | | - start_page: number, |
34 | | - end_page: number, |
35 | | - options?: ConversionOptions |
36 | | - ): Promise<ParsingStatus>; |
| 23 | + /** |
| 24 | + * Convert a specific range of pages |
| 25 | + * @param docx_file Output DOCX file path |
| 26 | + * @param start_page Starting page number (1-based) |
| 27 | + * @param end_page Ending page number (1-based) |
| 28 | + * @param options Conversion options |
| 29 | + * @returns Promise resolving to parsing status |
| 30 | + */ |
| 31 | + parsePages( |
| 32 | + docx_file: string, |
| 33 | + start_page: number, |
| 34 | + end_page: number, |
| 35 | + options?: ConversionOptions, |
| 36 | + ): Promise<ParsingStatus>; |
37 | 37 | } |
38 | 38 |
|
39 | 39 | export interface ConversionOptions { |
40 | | - start?: number; |
41 | | - end?: number; |
42 | | - pages?: number[]; |
43 | | - password?: string; |
44 | | - tables?: TableOptions; |
45 | | - images?: ImageOptions; |
46 | | - font_settings?: FontSettings; |
47 | | - page_margin?: MarginSettings; |
| 40 | + start?: number; |
| 41 | + end?: number; |
| 42 | + pages?: number[]; |
| 43 | + password?: string; |
| 44 | + tables?: TableOptions; |
| 45 | + images?: ImageOptions; |
| 46 | + font_settings?: FontSettings; |
| 47 | + page_margin?: MarginSettings; |
48 | 48 | } |
49 | 49 |
|
50 | 50 | export interface TableOptions { |
51 | | - extract_tables?: boolean; |
52 | | - cell_border_width?: number; |
53 | | - cell_margin?: number; |
| 51 | + extract_tables?: boolean; |
| 52 | + cell_border_width?: number; |
| 53 | + cell_margin?: number; |
54 | 54 | } |
55 | 55 |
|
56 | 56 | export interface ImageOptions { |
57 | | - extract_images?: boolean; |
58 | | - max_width?: number; |
59 | | - max_height?: number; |
| 57 | + extract_images?: boolean; |
| 58 | + max_width?: number; |
| 59 | + max_height?: number; |
60 | 60 | } |
61 | 61 |
|
62 | 62 | export interface FontSettings { |
63 | | - default_font_size?: number; |
64 | | - default_font_family?: string; |
65 | | - text_direction?: 'horizontal' | 'vertical'; |
| 63 | + default_font_size?: number; |
| 64 | + default_font_family?: string; |
| 65 | + text_direction?: "horizontal" | "vertical"; |
66 | 66 | } |
67 | 67 |
|
68 | 68 | export interface MarginSettings { |
69 | | - top?: number; |
70 | | - bottom?: number; |
71 | | - left?: number; |
72 | | - right?: number; |
| 69 | + top?: number; |
| 70 | + bottom?: number; |
| 71 | + left?: number; |
| 72 | + right?: number; |
73 | 73 | } |
74 | 74 |
|
75 | 75 | export interface ParsingStatus { |
76 | | - pages_processed: number; |
77 | | - status: string; |
78 | | - errors?: ParseError[]; |
| 76 | + pages_processed: number; |
| 77 | + status: string; |
| 78 | + errors?: ParseError[]; |
79 | 79 | } |
80 | 80 |
|
81 | 81 | export interface ParseError { |
82 | | - message: string; |
83 | | - page?: number; |
84 | | - code?: string; |
| 82 | + message: string; |
| 83 | + page?: number; |
| 84 | + code?: string; |
85 | 85 | } |
86 | 86 |
|
87 | 87 | /** |
88 | | -* Convert PDF to DOCX |
89 | | -* @param pdf_file Input PDF file path or Buffer |
90 | | -* @param docx_file Output DOCX file path |
91 | | -* @param options Conversion options |
92 | | -* @returns Promise resolving to parsing status |
93 | | -*/ |
| 88 | + * Convert PDF to DOCX |
| 89 | + * @param pdf_file Input PDF file path or Buffer |
| 90 | + * @param docx_file Output DOCX file path |
| 91 | + * @param options Conversion options |
| 92 | + * @returns Promise resolving to parsing status |
| 93 | + */ |
94 | 94 | export function convert( |
95 | | - pdf_file: string | Buffer, |
96 | | - docx_file: string, |
97 | | - options?: ConversionOptions |
| 95 | + pdf_file: string | Buffer, |
| 96 | + docx_file: string, |
| 97 | + options?: ConversionOptions, |
98 | 98 | ): Promise<ParsingStatus>; |
0 commit comments