How can I help you?
Enable print rotation in Angular PDF Viewer
13 Apr 20262 minutes to read
This guide shows how to enable automatic rotation of landscape pages during printing so they match the paper orientation and reduce clipping. Use enablePrintRotation when printing documents that include landscape pages and you want them rotated to match the printer paper orientation.
Prerequisites
- The
Printmodule must be injected intoPdfViewerComponent.
Steps to enable print rotation
- Inject the required modules (including
Print) intoPdfViewerComponent. - Set
enablePrintRotationtotruein the PDF Viewer during initialization.
Example
import { Component, ViewChild, OnInit } from '@angular/core';
import {
PdfViewerComponent,
PdfViewerModule,
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
TextSearchService,
TextSelectionService,
PrintService,
AnnotationService,
FormFieldsService,
FormDesignerService,
PageOrganizerService,
} from '@syncfusion/ej2-angular-pdfviewer';
@Component({
selector: 'app-root',
standalone: true,
imports: [PdfViewerModule],
providers: [
LinkAnnotationService,
BookmarkViewService,
MagnificationService,
ThumbnailViewService,
ToolbarService,
NavigationService,
TextSearchService,
TextSelectionService,
PrintService,
AnnotationService,
FormFieldsService,
FormDesignerService,
PageOrganizerService,
],
template: `
<ejs-pdfviewer
#pdfviewer
id="PdfViewer"
[documentPath]="document"
[resourceUrl]="resource"
[enablePrintRotation]="true"
style="height: 100vh; width: 100%; display: block"
>
</ejs-pdfviewer>
`,
})
export class AppComponent implements OnInit {
@ViewChild('pdfviewer')
public pdfviewerControl!: PdfViewerComponent;
public document: string =
'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf';
public resource: string =
'https://cdn.syncfusion.com/ej2/23.2.6/dist/ej2-pdfviewer-lib';
ngOnInit(): void {
// Initialization logic (if needed)
}
}
Troubleshooting
- If you need to preserve original page orientation for archival printing, set
enablePrintRotationtofalse. - Confirm that injected modules include
Printor the property will have no effect.