feat: конвертация бинарного .doc (Word 97-2003) в PDF (POI HWPF + FOP)

This commit is contained in:
Pjandro
2026-10-16 21:44:24 +00:00
parent e925242948
commit d72bf295ee
15 changed files with 1217 additions and 40 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ export async function convertDocx(
// флаг i обязателен; фолбэк — имя исходника с заменой расширения
const cd = resp.headers.get('Content-Disposition') ?? ''
const m = /filename\*=utf-8''([^;]+)/i.exec(cd)
const filename = m ? decodeURIComponent(m[1]) : file.name.replace(/\.docx$/i, '') + '.pdf'
const filename = m ? decodeURIComponent(m[1]) : file.name.replace(/\.docx?$/i, '') + '.pdf'
const blob = await resp.blob()
return { blob, filename }
}
+1 -1
View File
@@ -140,7 +140,7 @@ export default function App() {
<div>
<h1 className="text-2xl font-semibold">Word → PDF</h1>
<p className="mt-1 text-sm text-muted">
docx → PDF на docx4j + Apache FOP. Лимиты (файл ≤ 20 МБ,
docx/doc → PDF на docx4j + Apache FOP. Лимиты (файл ≤ 20 МБ,
≤ 1000 страниц) задаёт сервер; переопределение из формы убрано.
</p>
</div>
+3 -3
View File
@@ -8,7 +8,7 @@ interface Props {
}
/**
* Зона drag&drop + клик для выбора .docx. Скрытый input[type=file] —
* Зона drag&drop + клик для выбора .docx/.doc. Скрытый input[type=file] —
* единственный источник выбора; drop берёт первый файл.
*/
export default function DropZone({ file, disabled, onSelect }: Props) {
@@ -53,7 +53,7 @@ export default function DropZone({ file, disabled, onSelect }: Props) {
<path d="M12 16V4m0 0-4 4m4-4 4 4" />
<path d="M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3" />
</svg>
<span>Перетащите .docx сюда или нажмите для выбора</span>
<span>Перетащите .docx или .doc сюда или нажмите для выбора</span>
{file && (
<span className="text-sm text-muted">
{file.name} · {(file.size / 1024).toFixed(0)} КБ
@@ -62,7 +62,7 @@ export default function DropZone({ file, disabled, onSelect }: Props) {
<input
ref={inputRef}
type="file"
accept=".docx"
accept=".docx,.doc"
className="sr-only"
disabled={disabled}
onChange={(e) => {