[CLAUDE] App+Infra+Api+FE-Admin: PDF export (LibreOffice headless)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m33s
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 2m33s
Pipeline: template.docx → FormRenderer fill placeholders → LibreOffice
soffice --headless --convert-to pdf → PDF byte[] → File() stream to
browser.
Clean-arch split:
- Application: IPdfConverter abstraction (swap to QuestPDF/Aspose later
without touching caller).
- Infrastructure: LibreOfficePdfConverter — shells out to soffice.exe
path from config (Pdf:SofficePath, default
`C:\Program Files\LibreOffice\program\soffice.exe` on Windows).
Per-request temp workDir để tránh filename collision + -env:
UserInstallation isolate mỗi conversion (chống "soffice already
running" khi concurrent). Timeout 60s (configurable). Best-effort
cleanup. Kill entire process tree nếu timeout.
- Application: ExportTemplatePdfCommand — reuses existing FormRenderer
+ pipes bytes through IPdfConverter. Same data dict signature as
Render để UI code share.
- Api: POST /api/forms/templates/{id}/export-pdf (same JSON body as
/render, returns PDF stream).
FE:
- useExport hook chung cho 2 endpoints (DRY render + export-pdf mutations)
- Render dialog thêm nút "Tải PDF" (outline variant) cạnh "Tải file gốc".
Disabled khi mutation khác đang chạy.
- Hướng dẫn dialog nâng cấp: "file gốc để edit Word/Excel, PDF để
in/gửi không chỉnh sửa được".
Ops: scripts/install-libreoffice.ps1 — silent MSI install 25.8.6 cho
VPS (đã chạy trên prod).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
16
scripts/install-libreoffice.ps1
Normal file
16
scripts/install-libreoffice.ps1
Normal file
@ -0,0 +1,16 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$url = 'https://download.documentfoundation.org/libreoffice/stable/25.8.6/win/x86_64/LibreOffice_25.8.6_Win_x86-64.msi'
|
||||
$msi = 'C:\Windows\Temp\lo.msi'
|
||||
Write-Host "Downloading LibreOffice 25.8.6..."
|
||||
Invoke-WebRequest -Uri $url -OutFile $msi -UseBasicParsing
|
||||
Write-Host ("Downloaded {0:N1} MB" -f ((Get-Item $msi).Length / 1MB))
|
||||
Write-Host "Installing silently (4-6 min)..."
|
||||
$p = Start-Process msiexec.exe -ArgumentList '/i', $msi, '/quiet', '/norestart', 'ADDLOCAL=ALL', 'CREATEDESKTOPLINK=0' -Wait -PassThru
|
||||
Write-Host "Exit code: $($p.ExitCode)"
|
||||
Remove-Item $msi -ErrorAction SilentlyContinue
|
||||
if (Test-Path 'C:\Program Files\LibreOffice\program\soffice.exe') {
|
||||
Write-Host "OK: soffice.exe installed"
|
||||
& 'C:\Program Files\LibreOffice\program\soffice.exe' --version
|
||||
} else {
|
||||
Write-Error "soffice.exe NOT found after install"
|
||||
}
|
||||
Reference in New Issue
Block a user