Page Manipulation
Execute page-level operations including rotate, delete, insert, copy, paste, and blank page creation.
Use viewer.documents.manipulatePages(...) to run page-level PDF operations in Canvas.
Page manipulation is available after the viewer is mounted, ready, and a PDF is open.
displayNamemust include the file extension.
Invoke the manipulatePages method to perform operations.
- The SDK sends
pageManipulationand waits for the matchingpageManipulationResult.
Supported workflows and actions:
- Move pages:
move-top,move-bottom,move-up,move-down(targetspageRange) - Rotate pages:
rotate-r,rotate-l(targetspageRange) - Copy/paste pages:
page-copy(targetspageRangefor copy),page-paste(targetstargetPageIndexfor paste) - Extract/delete pages:
page-extract,page-extract-delete,page-delete(targetspageRange) - Insert/replace from file:
page-insert,page-replace(targetspageRange,file,selectedPages) - Insert blank pages:
page-insert-blank(targetspageRange,count,width,height) pageRangeuses Canvas page indexes, not human-facing page numbers (e.g.pageRange: [[0], [3, 5]]targets page index0and inclusive range3through5).
Rotate specific pages in the PDF document.
- Use
rotate-lfor left rotation.
Reorder existing pages in the active PDF.
- Move actions reorder existing pages in the active PDF. The SDK does not send page bytes, file URLs, or source files for move operations.
Copy pages to the Canvas clipboard and paste them at a target index.
- Copy and paste use Canvas session state.
page-pastecan fail if nothing was copied in the same viewer session.
Extract range of pages or delete pages from the current PDF.
- Use
page-extract-deletewhen Canvas should extract pages and remove them from the active PDF.
Use a browser File for source PDF pages. Canvas expects the file directly; do not pass a URL for this workflow.
pageRangeis the insertion location in the active PDF.selectedPagesidentifies pages from the source file.
Replace pages in the current document with pages from another PDF file.
Insert blank pages specifying width and height.
- Canvas interprets
widthandheightas document units for the blank page.
Handle result resolution and promise rejections.
- The promise rejects when:
viewer.ready()has not completed, Canvas reportssuccess: false, Canvas returns an empty result, Canvas result does not include the matchingrequestId, or no matching result arrives beforetimeoutMs. - Use
timeoutMsfor larger operations, such as:
Operation Timeout Example
Complete implementation details for Vanilla HTML/TypeScript setups:
Implement page manipulation inside a React functional component:
Use the SDK within a client component in Next.js:
Leverage the SDK inside Angular component logic:
The package exports the page manipulation types for compile-time safety:
Maps the SDK API to Canvas internal command/event triggers:
viewer.documents.manipulatePages(...)maps topageManipulation/pageManipulationResult.
