diff --git a/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.html b/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.html
index 9d88175c4c..e0794193ad 100644
--- a/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.html
+++ b/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.html
@@ -106,6 +106,14 @@
+
+
-
diff --git a/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.spec.ts b/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.spec.ts
index 3bdf41f247..4e712dd1e5 100644
--- a/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.spec.ts
+++ b/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.spec.ts
@@ -461,8 +461,10 @@ describe('Test PdfViewer - User interaction', () => {
let component: PdfViewerComponent;
let testingUtils: UnitTestingUtils;
let pdfViewerSpy: jasmine.Spy;
+ let pageViewMock: { width: number; height: number; scale: number; rotation: number; update: jasmine.Spy };
beforeEach(fakeAsync(() => {
+ pageViewMock = { width: 100, height: 100, scale: 1, rotation: 0, update: jasmine.createSpy() };
pdfViewerSpy = jasmine.createSpy('PDFViewer').and.returnValue({
setDocument: jasmine.createSpy().and.returnValue({
loadingTask: () => ({
@@ -479,7 +481,7 @@ describe('Test PdfViewer - User interaction', () => {
update: jasmine.createSpy(),
currentScaleValue: 1,
_currentPageNumber: 1,
- _pages: [{ width: 100, height: 100, scale: 1 }]
+ _pages: [pageViewMock]
});
TestBed.configureTestingModule({
@@ -617,6 +619,30 @@ describe('Test PdfViewer - User interaction', () => {
}), 300);
});
+ describe('Rotation', () => {
+ it('should rotate only the current page counter-clockwise by 90 degrees', () => {
+ testingUtils.clickByCSS('#viewer-rotate-page-button');
+
+ expect(pageViewMock.update).toHaveBeenCalledWith({ rotation: 270 });
+ });
+
+ it('should wrap rotation back to 0 after a full turn', () => {
+ pageViewMock.rotation = 90;
+
+ testingUtils.clickByCSS('#viewer-rotate-page-button');
+
+ expect(pageViewMock.update).toHaveBeenCalledWith({ rotation: 0 });
+ });
+
+ it('should recompute the document overflow after rotation', () => {
+ spyOn(component, 'setDocumentOverflow');
+
+ testingUtils.clickByCSS('#viewer-rotate-page-button');
+
+ expect(component.setDocumentOverflow).toHaveBeenCalled();
+ });
+ });
+
describe('Resize interaction', () => {
it('should resize event trigger setScaleUpdatePages', () => {
spyOn(component, 'onResize');
diff --git a/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.ts b/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.ts
index d1a91c5690..6c1c13d97a 100644
--- a/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.ts
+++ b/lib/core/viewer/pdf/src/lib/components/pdf-viewer/pdf-viewer.component.ts
@@ -577,6 +577,24 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
this.setScaleUpdatePages(newScale);
}
+ /**
+ * Rotate the currently displayed page 90 degrees counter-clockwise.
+ *
+ * Only the current page is affected; every other page keeps its own rotation.
+ * The angle wraps around, so four consecutive calls return the page to its
+ * original orientation (0 → 270 → 180 → 90 → 0). The document overflow state
+ * is recomputed afterwards, since rotation swaps the page width and height.
+ */
+ rotatePage() {
+ if (this.pdfViewer) {
+ const pageView = this.pdfViewer._pages[this.pdfViewer._currentPageNumber - 1];
+ if (pageView) {
+ pageView.update({ rotation: (pageView.rotation + 270) % 360 });
+ this.setDocumentOverflow();
+ }
+ }
+ }
+
/**
* load the previous page
*/