mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-12 09:34:01 +01:00
feat: translate all pages, UI messages and docs and fix SEO redirects and indexing
This commit is contained in:
1 parent
5e019de5ae
commit
4edb1718cc
3344 files changed
+415643
-4759
No files matched your search
@@ -2,6 +2,8 @@ import { getCpdf, isCpdfAvailable } from './cpdf-helper';
|
||||
import { isPyMuPDFAvailable, loadPyMuPDF } from './pymupdf-loader';
|
||||
import type { CpdfInstance } from '@/types';
|
||||
|
||||
import { trText } from '../i18n/i18n.js';
|
||||
|
||||
export type PdfDecryptEngine = 'cpdf' | 'pymupdf';
|
||||
|
||||
export interface PdfDecryptResult {
|
||||
@@ -76,7 +78,7 @@ async function decryptWithCpdf(
|
||||
pdf = null;
|
||||
|
||||
if (!(outputBytes instanceof Uint8Array) || outputBytes.length === 0) {
|
||||
throw new Error('CoherentPDF produced an empty decrypted file.');
|
||||
throw new Error(trText('CoherentPDF produced an empty decrypted file.'));
|
||||
}
|
||||
|
||||
return copyBytes(outputBytes);
|
||||
@@ -102,13 +104,15 @@ async function decryptWithPyMuPDF(
|
||||
if (document.needsPass || document.isEncrypted) {
|
||||
const authenticated = document.authenticate(password);
|
||||
if (!authenticated) {
|
||||
throw new Error('Invalid PDF password.');
|
||||
const error = new Error(trText('Invalid PDF password.'));
|
||||
error.name = 'PasswordError';
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
const outputBytes = document.save();
|
||||
if (!(outputBytes instanceof Uint8Array) || outputBytes.length === 0) {
|
||||
throw new Error('PyMuPDF produced an empty decrypted file.');
|
||||
throw new Error(trText('PyMuPDF produced an empty decrypted file.'));
|
||||
}
|
||||
|
||||
return copyBytes(outputBytes);
|
||||
@@ -145,7 +149,7 @@ export async function decryptPdfBytes(
|
||||
console.info(
|
||||
`${DECRYPT_LOG_PREFIX} CoherentPDF is not configured, skipping to PyMuPDF`
|
||||
);
|
||||
errors.push('CoherentPDF: not configured.');
|
||||
errors.push(trText('CoherentPDF: not configured.'));
|
||||
}
|
||||
|
||||
if (isPyMuPDFAvailable()) {
|
||||
@@ -166,7 +170,7 @@ export async function decryptPdfBytes(
|
||||
}
|
||||
} else {
|
||||
console.warn(`${DECRYPT_LOG_PREFIX} PyMuPDF is not configured`);
|
||||
errors.push('PyMuPDF: not configured.');
|
||||
errors.push(trText('PyMuPDF: not configured.'));
|
||||
}
|
||||
|
||||
throw new Error(errors.join('\n'));
|
||||
|
||||
Reference in new issue
Block a user