* Execute document conversion
(paramsPath: string)
| 145 | * Execute document conversion |
| 146 | */ |
| 147 | private executeConversion(paramsPath: string): void { |
| 148 | if (!this.x2tModule) { |
| 149 | throw new Error('X2T module not initialized'); |
| 150 | } |
| 151 | |
| 152 | const result = this.x2tModule.ccall('main1', 'number', ['string'], [paramsPath]); |
| 153 | if (result !== 0) { |
| 154 | // Read the params XML for debugging |
| 155 | try { |
| 156 | const paramsContent = this.x2tModule.FS.readFile(paramsPath, { encoding: 'binary' }); |
| 157 | // Convert binary to string for logging |
| 158 | if (paramsContent instanceof Uint8Array) { |
| 159 | const paramsText = new TextDecoder('utf-8').decode(paramsContent); |
| 160 | console.error('Conversion failed. Parameters XML:', paramsText); |
| 161 | } else { |
| 162 | console.error('Conversion failed. Parameters XML:', paramsContent); |
| 163 | } |
| 164 | } catch (e) { |
| 165 | console.error('Conversion failed. Parameters XML:', e); |
| 166 | // Ignore if we can't read the params file |
| 167 | } |
| 168 | throw new Error(`Conversion failed with code: ${result}`); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Create conversion parameters XML |
no test coverage detected