Add direct image download to pdf-to-jpg

This commit is contained in:
Sebastian Espei
2026-03-09 16:46:05 +01:00
parent 1625ba0f45
commit 22ff7f435c
3 changed files with 211 additions and 148 deletions

View File

@@ -460,3 +460,22 @@ export function formatRawDate(raw: string): string {
}
return raw;
}
/**
* Returns a sanitized PDF filename.
*
* The provided filename is processed as follows:
* - Removes a trailing `.pdf` file extension (case-insensitive)
* - Trims leading and trailing whitespace
* - Truncates the name to a maximum of 80 characters
*
* @param filename The original filename (including extension)
* @returns The sanitized filename without the `.pdf` extension, limited to 80 characters
*/
export function getCleanPdfFilename(filename: string): string {
let clean = filename.replace(/\.pdf$/i, '').trim();
if (clean.length > 80) {
clean = clean.slice(0, 80);
}
return clean;
}