Page rotations are not saved on export

WebViewer Version: latest

I’ve got a button to apply rotation on specific pages of a document like the following:

const getRotation = (curr) => {
    const {
        E_0, E_90, E_180, E_270
    } = webViewerInstance.Core.PageRotation;

    switch (curr) {
        case 270:
        case 3:
            return E_270;
        case 180:
        case 2:
            return E_180;
        case 90:
        case 1:
            return E_90;
            return E_0;

// Add rotation button to main toolbar
webViewerInstance.UI.setHeaderItems((header) => {
        type: 'actionButton',
        dataElement: 'rotateCustomButton',
        img: 'icon-header-page-manipulation-page-rotation-clockwise-fill',
        onClick: () => {
            const pageNum = documentViewer.getCurrentPage();
            const currentRotations = documentViewer.getPageRotations();
            const rotation = getNewRotation(currentRotations[pageNum]);
            documentViewer.setRotation(rotation, pageNum);
            documentViewer.trigger(customEvent.ROTATE_PAGE, { pageNum, rotation });

So I’ve got a document with some pages rotated. But while exporting / downloading them from the viewer, no rotations are saved on the pages.

I’ve got a button as follows:

// Customized download button to avoid downloading PDFs with annotations
webViewerInstance.UI.updateElement('downloadButton', {
    onClick: () => {
            includeAnnotations: false

No options are available to enable keeping the rotations applied.
Is there any way to do this?

Regards :vulcan_salute:

Hi m.lafarie,

Thank you for contacting us regarding Webviewer.

Could you try the following code and see if it works for you? In the onClick block, instead of using setRoation, use doc.rotatePages method.

const rotation = instance.Core.PageRotation;
const pageNumber = documentViewer.getCurrentPage();
const doc = documentViewer.getDocument();
await doc.rotatePages([pageNumber], rotation.E_90) // or the value you want to rotate

I was able to rotate the page and download the pdf with that page rotated.

Please let us know if this works for you, thank you.