This commit is contained in:
1 parent
891026ccbb
commit
adaae41e44
33 files changed
+2771
-396
No files matched your search
@@ -572,6 +572,25 @@ export const dissolveSubDocument = (
|
||||
const stripPdfExtension = (name: string) =>
|
||||
name.toLowerCase().endsWith('.pdf') ? name.slice(0, -'.pdf'.length) : name;
|
||||
|
||||
/**
|
||||
* Build a single PDF export unit for one sub-document. The resulting filename
|
||||
* follows the same convention as the separate archive export:
|
||||
* `{archiveName} - {subDocumentName}` (without duplicate `.pdf` suffixes).
|
||||
*/
|
||||
export const buildSubDocumentExport = async (
|
||||
archiveName: string,
|
||||
subDocument: SubDocument
|
||||
): Promise<ExportUnit> => {
|
||||
if (subDocument.attachments.length === 0) {
|
||||
throw new Error('Cannot create a PDF from an empty sub-document.');
|
||||
}
|
||||
|
||||
return {
|
||||
name: `${stripPdfExtension(archiveName)} - ${stripPdfExtension(subDocument.name)}`,
|
||||
bytes: await mergeAttachments(subDocument.attachments)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Build one or more PDF export units from the archive.
|
||||
*
|
||||
@@ -607,10 +626,7 @@ export const buildArchiveExport = async (
|
||||
continue;
|
||||
}
|
||||
|
||||
separateUnits.push({
|
||||
name: `${stripPdfExtension(archive.name)} - ${stripPdfExtension(subDocument.name)}`,
|
||||
bytes: await mergeAttachments(subDocument.attachments)
|
||||
});
|
||||
separateUnits.push(await buildSubDocumentExport(archive.name, subDocument));
|
||||
}
|
||||
|
||||
if (archive.attachments.length > 0) {
|
||||
|
||||
Reference in new issue
Block a user