Cleanup, Documented Impose
This commit is contained in:
@@ -5,19 +5,19 @@ import { parsePageIndexSpecification } from './common/pageIndexesUtils'
|
||||
|
||||
export type ExtractPagesParamsType = {
|
||||
file: PdfFile;
|
||||
pageIndexes: string | number[];
|
||||
pageIndecies: string | number[];
|
||||
}
|
||||
export async function extractPages(params: ExtractPagesParamsType): Promise<PdfFile> {
|
||||
const { file, pageIndexes } = params;
|
||||
const { file, pageIndecies: pageIndecies } = params;
|
||||
const pdfLibDocument = await file.pdfLibDocument;
|
||||
|
||||
var indexes = pageIndexes;
|
||||
var indecies = pageIndecies;
|
||||
|
||||
if (!Array.isArray(indexes)) {
|
||||
indexes = parsePageIndexSpecification(indexes, pdfLibDocument.getPageCount());
|
||||
if (!Array.isArray(indecies)) {
|
||||
indecies = parsePageIndexSpecification(indecies, pdfLibDocument.getPageCount());
|
||||
}
|
||||
|
||||
const newFile = await getPages(file, indexes);
|
||||
const newFile = await getPages(file, indecies);
|
||||
newFile.filename += "_extractedPages"
|
||||
return newFile;
|
||||
}
|
||||
|
||||
@@ -2,17 +2,16 @@ import { PdfFile, RepresentationType } from "../wrappers/PdfFile";
|
||||
|
||||
export type ImposeParamsType = {
|
||||
file: PdfFile;
|
||||
/** Accepted values are 2, 3, 4, 8, 9, 12, 16 - see: {@link https://pdfcpu.io/generate/nup.html#n-up-value} */
|
||||
nup: number;
|
||||
/** A0-A10, other formats available - see: {@link https://pdfcpu.io/paper.html} */
|
||||
format: string;
|
||||
}
|
||||
export type ImposeParamsBaseType = {
|
||||
file: PdfFile;
|
||||
nup: number;
|
||||
format: string;
|
||||
pdfcpuWrapper: any;
|
||||
}
|
||||
export async function impose(params: ImposeParamsBaseType): Promise<PdfFile> {
|
||||
const uint8Array = await params.pdfcpuWrapper.oneToOne(
|
||||
|
||||
/** PDF-Imposition, PDF-N-Up: Put multiple pages of the input document into a single page of the output document. - see: {@link https://en.wikipedia.org/wiki/N-up} */
|
||||
export async function impose(params: ImposeParamsType, pdfcpuWrapper: any): Promise<PdfFile> {
|
||||
// https://pdfcpu.io/generate/nup.html
|
||||
const uint8Array = await pdfcpuWrapper.oneToOne(
|
||||
[
|
||||
"pdfcpu.wasm",
|
||||
"nup",
|
||||
|
||||
Reference in New Issue
Block a user