Modern web applications often need more than just PDF viewing—they require the ability to modify documents directly. With WebViewer’s JavaScript PDF library, developers can perform powerful PDF page manipulations entirely on the client side.
When running in client-only mode, WebViewer can make permanent changes to PDF documents, including:
Unlike temporary viewer adjustments, these changes are applied directly to the PDF data. When users download the file or export it using getFileData(), the modified document can be opened in any PDF viewer with all changes preserved.
With just a few lines of code, you can rotate a page in a PDF document:
WebViewer({path: '/webviewer/lib',initialDoc: '/files/sample.pdf'}, document.getElementById('viewer')).then(async (instance) => {const { documentViewer } = instance.Core;documentViewer.addEventListener('documentLoaded', async () => {const doc = documentViewer.getDocument();// Rotate page 1 by 90 degreesawait doc.rotatePages([1], 90);// Export the updated PDFconst data = await doc.getFileData();});});
The updated PDF will retain the page rotation when downloaded or opened in another PDF viewer.
WebViewer enables a wide range of document assembly and editing workflows:
Page manipulation features are designed for PDFs. If you’re working with Office files such as DOCX, XLSX, or PPTX, enable the loadAsPDF: true option to automatically convert them to PDF before editing.
For WebViewer Server deployments, use forceClientSideInit: true to switch processing to the client and enable page manipulation capabilities.
PDF page manipulation is ideal for: