isPortrait
Determines whether a page has portrait orientation (height > width).
isPortrait()
Determines whether a page has portrait orientation (height > width). Defaults to checking the current page if no page number is specified.
Returns: Promise<boolean> — true if portrait, false if landscape
Parameters
Prop
Type
Implementation
<button id="checkOrientationBtn">Check Current Page Orientation</button>
<p id="orientationResult"></p>
<button id="checkPage1Btn">Check Page 1</button>
<button id="checkPage2Btn">Check Page 2</button>
<pdf-atelier id="pdfAtelier" license="My License" src="/document.pdf"></pdf-atelier>
<script>
const checkOrientationBtn = document.getElementById('checkOrientationBtn');
const orientationResult = document.getElementById('orientationResult');
const checkPage1Btn = document.getElementById('checkPage1Btn');
const checkPage2Btn = document.getElementById('checkPage2Btn');
const pdfAtelier = document.getElementById('pdfAtelier');
checkOrientationBtn.addEventListener('click', async () => {
const isPortrait = await pdfAtelier.isPortrait();
orientationResult.textContent = `Current page: ${isPortrait ? 'portrait' : 'landscape'}`;
});
checkPage1Btn.addEventListener('click', async () => {
const isPortrait = await pdfAtelier.isPortrait(1);
console.log(`Page 1 is ${isPortrait ? 'portrait' : 'landscape'}`);
});
checkPage2Btn.addEventListener('click', async () => {
const isPortrait = await pdfAtelier.isPortrait(2);
console.log(`Page 2 is ${isPortrait ? 'portrait' : 'landscape'}`);
});
</script>import { useState, useRef } from 'react';
import { PDFAtelier, type PDFAtelierRef } from '@innosoft/pdf-atelier-react';
export default function OrientationDetector() {
const pdfRef = useRef<PDFAtelierRef>(null);
const [orientation, setOrientation] = useState<
'portrait' | 'landscape' | null
>(null);
const checkOrientation = async () => {
const isPortrait = await pdfRef.current?.isPortrait();
setOrientation(isPortrait ? 'portrait' : 'landscape');
};
const checkSpecificPage = async (pageNum: number) => {
const isPortrait = await pdfRef.current?.isPortrait(pageNum);
console.log(
`Page ${pageNum} is ${isPortrait ? 'portrait' : 'landscape'}`,
);
};
return (
<>
<button onClick={checkOrientation}>
Check Current Page Orientation
</button>
{orientation && <p>Current page: {orientation}</p>}
<button onClick={() => checkSpecificPage(1)}>Check Page 1</button>
<button onClick={() => checkSpecificPage(2)}>Check Page 2</button>
<PDFAtelier
ref={pdfRef}
src="/document.pdf"
license="My License"
/>
</>
);
}import { Component, ViewChild } from '@angular/core';
import { PdfAtelierWrapper } from '@innosoft/pdf-atelier-angular';
@Component({
standalone: true,
selector: 'app-orientation',
imports: [PdfAtelierWrapper],
template: `
<button (click)="checkCurrentPage()">Check Orientation</button>
<p *ngIf="orientation">{{ orientation }}</p>
<pdf-atelier-wrapper
[src]="'/document.pdf'"
[license]="'My License'"
></pdf-atelier-wrapper>
`,
})
export class OrientationComponent {
@ViewChild(PdfAtelierWrapper) pdfAtelier!: PdfAtelierWrapper;
orientation: string | null = null;
async checkCurrentPage() {
const isPortrait = await this.pdfAtelier.isPortrait();
this.orientation = isPortrait ? 'Portrait' : 'Landscape';
}
}<script setup lang="ts">
import { ref } from 'vue';
import PdfAtelierWrapper from '@innosoft/pdf-atelier-vue';
interface PdfAtelierExposed {
isPortrait(pageNumber?: number): Promise<boolean>;
}
const pdfRef = ref<PdfAtelierExposed | null>(null);
const orientationInfo = ref<string | null>(null);
const checkAllPages = async () => {
const isPortrait1 = await pdfRef.value?.isPortrait(1);
const isPortrait2 = await pdfRef.value?.isPortrait(2);
orientationInfo.value = `Page 1: ${isPortrait1 ? 'portrait' : 'landscape'}, Page 2: ${isPortrait2 ? 'portrait' : 'landscape'}`;
};
</script>
<template>
<div>
<button @click="checkAllPages">Check All Pages</button>
<p v-if="orientationInfo">{{ orientationInfo }}</p>
<PdfAtelierWrapper
ref="pdfRef"
:src="'/document.pdf'"
:license="'My License'"
/>
</div>
</template>