diff --git a/src/webparts/ctFormsPortal/forms/ct/components/Step2CommercialOffers/useKpProcessing.ts b/src/webparts/ctFormsPortal/forms/ct/components/Step2CommercialOffers/useKpProcessing.ts index 32d3fee..9caf562 100644 --- a/src/webparts/ctFormsPortal/forms/ct/components/Step2CommercialOffers/useKpProcessing.ts +++ b/src/webparts/ctFormsPortal/forms/ct/components/Step2CommercialOffers/useKpProcessing.ts @@ -240,6 +240,7 @@ export function useKpProcessing( patchFile(entry.localId, { spId, status: 'extracting' }); const isWord = /\.(doc|docx|xls|xlsx)$/i.test(entry.file.name); + const isPdf = /\.pdf$/i.test(entry.file.name); if (isWord) { try { await service.extractWordText(spId); @@ -247,6 +248,13 @@ export function useKpProcessing( patchFile(entry.localId, { status: 'error', error: `Ошибка извлечения текста Word: ${(err as Error).message}` }); continue; } + } else if (isPdf) { + try { + await service.extractPDFText(spId); + } catch (err) { + patchFile(entry.localId, { status: 'error', error: `Ошибка извлечения текста PDF: ${(err as Error).message}` }); + continue; + } } pollSyntex(entry.localId, spId, name, 0).catch(err => { diff --git a/src/webparts/ctFormsPortal/forms/ct/services/CtService.ts b/src/webparts/ctFormsPortal/forms/ct/services/CtService.ts index 6fcdec2..4cbefb4 100644 --- a/src/webparts/ctFormsPortal/forms/ct/services/CtService.ts +++ b/src/webparts/ctFormsPortal/forms/ct/services/CtService.ts @@ -1406,6 +1406,24 @@ export class CtService { throw new Error(`Ошибка извлечения текста Word: ${res.status}`); } + async extractPDFText(itemId: number): Promise { + const token = await this._getApiToken(); + const res = await fetch(`${EXTERNAL_API}/Document/extractPDFText`, { + method: "POST", + headers: { + Authorization: `Bearer ${token}`, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + siteUrl: this.baseUrl, + libraryName: KP_LIBRARY_DISPLAY_NAME, + itemId: String(itemId), + }), + }); + if (!res.ok) + throw new Error(`Ошибка извлечения текста PDF: ${res.status}`); + } + async triggerFlow( fileName: string, fileId: number,