Appearance
Function: pdfExtractRanges()
ts
function pdfExtractRanges(mwFile: MwFile, ranges: PageRange[]): Promise<MwFile>;Defined in: src/file/pdf.ts:346
Extract page ranges from a PDF and combine them into a new file.
Each range is a [start, end] pair of zero-based page indices (inclusive).
Parameters
| Parameter | Type | Description |
|---|---|---|
mwFile | MwFile | The source PDF as an MwFile. |
ranges | PageRange[] | An array of [start, end] page ranges to include. |
Returns
Promise<MwFile>
A new MwFile containing only the selected page ranges.
Example
ts
const manual = convertBase64ToMwFile(manualBase64, 'manual.pdf', 'application/pdf');
const chapters = await pdfExtractRanges(manual, [[0, 2], [10, 15]]);
console.log(chapters.name); // 'manual.pdf'