Skip to content

Commit

Permalink
Merge pull request #26 from SyncfusionExamples/EJ2-910172-getPageInfo
Browse files Browse the repository at this point in the history
910172: Sample for How to get Page details
  • Loading branch information
rparthi-pdf authored Dec 12, 2024
2 parents 342453f + a17fc4e commit 9f0f75d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
38 changes: 38 additions & 0 deletions How to/Get Page Details/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html><html lang="en"><head>
<title>EJ2 PDF Viewer</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Typescript PDF Viewer Control">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-pdfviewer/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-popups/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-lists/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-notifications/styles/material.css" rel="stylesheet">

<!-- Essential JS 2 PDF Viewer's script -->
<script src="https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>

<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<button id="getPageInfo">getPageInfo</button>
<div id="container">
<div id="PdfViewer" style="height:500px;width:100%;"></div>
</div>


<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body></html>
22 changes: 22 additions & 0 deletions How to/Get Page Details/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var pdfviewer = new ej.pdfviewer.PdfViewer({
documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',
resourceUrl: "https://cdn.syncfusion.com/ej2/27.2.2/dist/ej2-pdfviewer-lib",
});
ej.pdfviewer.PdfViewer.Inject(ej.pdfviewer.TextSelection, ej.pdfviewer.TextSearch, ej.pdfviewer.Print, ej.pdfviewer.Navigation, ej.pdfviewer.Toolbar,
ej.pdfviewer.Magnification, ej.pdfviewer.Annotation, ej.pdfviewer.FormDesigner, ej.pdfviewer.FormFields, ej.pdfviewer.PageOrganizer);
pdfviewer.appendTo('#PdfViewer');

document.getElementById('getPageInfo').addEventListener('click', function() {
// Set the page index for which info is required
let pageIndex=0;
// To Retrieve and log the page information
console.log(pdfviewer.getPageInfo(pageIndex));
// To Log the specific page information details to the console
const pageInfo = pdfviewer.getPageInfo(pageIndex);
console.log(`Page Info for Page Index ${pageIndex}:`);
console.log(`Height: ${pageInfo.height}`);
console.log(`Width: ${pageInfo.width}`);
console.log(`Rotation: ${pageInfo.rotation}`);
});


0 comments on commit 9f0f75d

Please sign in to comment.