2023-11-15 00:24:04 +01:00
|
|
|
import { PdfFile, RepresentationType } from "../wrappers/PdfFile";
|
|
|
|
|
2023-11-14 03:26:42 +03:00
|
|
|
export type ImposeParamsType = {
|
2023-11-15 00:24:04 +01:00
|
|
|
file: PdfFile;
|
2023-11-14 03:26:42 +03:00
|
|
|
nup: number;
|
|
|
|
format: string;
|
|
|
|
}
|
|
|
|
export type ImposeParamsBaseType = {
|
2023-11-15 00:24:04 +01:00
|
|
|
file: PdfFile;
|
2023-11-14 03:26:42 +03:00
|
|
|
nup: number;
|
|
|
|
format: string;
|
|
|
|
pdfcpuWrapper: any;
|
|
|
|
}
|
2023-11-15 00:24:04 +01:00
|
|
|
export async function impose(params: ImposeParamsBaseType): Promise<PdfFile> {
|
|
|
|
const result = new PdfFile(params.file.originalFilename, await params.pdfcpuWrapper.oneToOne([
|
2023-10-18 23:56:56 +02:00
|
|
|
"pdfcpu.wasm",
|
|
|
|
"nup",
|
|
|
|
"-c",
|
|
|
|
"disable",
|
2023-11-14 03:26:42 +03:00
|
|
|
'f:' + params.format,
|
2023-10-18 23:56:56 +02:00
|
|
|
"/output.pdf",
|
2023-11-14 03:26:42 +03:00
|
|
|
String(params.nup),
|
2023-10-18 23:56:56 +02:00
|
|
|
"input.pdf",
|
2023-11-15 00:24:04 +01:00
|
|
|
], await params.file.uint8Array), RepresentationType.Uint8Array, params.file.filename + "_imposed");
|
|
|
|
console.log("ImposeResult: ", result);
|
|
|
|
return result;
|
2023-10-18 01:20:31 +02:00
|
|
|
}
|