View a PDF
This sample demonstrates how to initialize a turnkey version of the PDF Viewer. The Viewer is embedded into a webpage and dynamically appended to a container using the PDF Viewer SDK. It provides a simple setup to load and view PDF documents.
HTML (index.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PDF Viewer SDK</title>
</head>
<body>
<div
id="pdftools-web-viewer-container"
style="width:100vw; height: 100vh;"
></div>
</body>
</html>
TypeScript (index.ts)
import { PdfToolsViewer } from "@pdftools/pdf-web-viewer";
async function initialize() {
const pdfWebViewer = await PdfToolsViewer.init();
const container = document.getElementById("pdftools-web-viewer-container");
container.append(pdfWebViewer);
}
initialize();