enes
b6479db266
Some checks failed
Open PR on Staging / audit_and_check (pull_request) Failing after 33s
25 lines
754 B
TypeScript
25 lines
754 B
TypeScript
import { Meta } from '../types'
|
|
import { extractMarksFromSignedMeta } from './mark.ts'
|
|
import { addMarks, convertToPdfBlob, groupMarksByFileNamePage } from './pdf.ts'
|
|
import JSZip from 'jszip'
|
|
import { PdfFile } from '../types/drawing.ts'
|
|
|
|
const getZipWithFiles = async (
|
|
meta: Meta,
|
|
files: { [filename: string]: PdfFile }
|
|
): Promise<JSZip> => {
|
|
const zip = new JSZip()
|
|
const marks = extractMarksFromSignedMeta(meta)
|
|
const marksByFileNamePage = groupMarksByFileNamePage(marks)
|
|
|
|
for (const [fileName, pdf] of Object.entries(files)) {
|
|
const pages = await addMarks(pdf.file, marksByFileNamePage[fileName])
|
|
const blob = await convertToPdfBlob(pages)
|
|
zip.file(`files/${fileName}`, blob)
|
|
}
|
|
|
|
return zip
|
|
}
|
|
|
|
export { getZipWithFiles }
|