feat: add translated PDF export with layout preservation
Adds the ability to download translated documents as PDF files while
preserving the original document layout. Key changes:
- Add apply_translations() function to merge translation JSON with UnifiedDocument
- Add generate_translated_pdf() method to PDFGeneratorService
- Add POST /api/v2/translate/{task_id}/pdf endpoint
- Add downloadTranslatedPdf() method and PDF button in frontend
- Add comprehensive unit tests (52 tests: merge, PDF generation, API endpoints)
- Archive add-translated-pdf-export proposal
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -686,6 +686,23 @@ class ApiClientV2 {
|
||||
async deleteTranslation(taskId: string, lang: string): Promise<void> {
|
||||
await this.client.delete(`/translate/${taskId}/translations/${lang}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Download translated PDF with layout preservation
|
||||
*/
|
||||
async downloadTranslatedPdf(taskId: string, lang: string): Promise<void> {
|
||||
const response = await this.client.post(`/translate/${taskId}/pdf`, null, {
|
||||
params: { lang },
|
||||
responseType: 'blob',
|
||||
})
|
||||
|
||||
const blob = new Blob([response.data], { type: 'application/pdf' })
|
||||
const link = document.createElement('a')
|
||||
link.href = window.URL.createObjectURL(blob)
|
||||
link.download = `${taskId}_translated_${lang}.pdf`
|
||||
link.click()
|
||||
window.URL.revokeObjectURL(link.href)
|
||||
}
|
||||
}
|
||||
|
||||
// Export singleton instance
|
||||
|
||||
Reference in New Issue
Block a user