44 lines
1.4 KiB
HTML
44 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<base href="/">
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>PDF Form Fields</title>
|
|
<script src="https://unpkg.com/pdf-lib/dist/pdf-lib.js"></script>
|
|
</head>
|
|
<body>
|
|
<h1>Hardcoded PDF Form Fields</h1>
|
|
<ul id="field-list"></ul>
|
|
|
|
<script>
|
|
|
|
const filePath = "/PDF/Template-EDV-ERT_v4.1.pdf"
|
|
|
|
const pdfBytes = await fetchPdfBytes(filePath);
|
|
// Function to load a PDF and list all form fields
|
|
async function listPdfFields(pdfBytes) {
|
|
const pdfDoc = await PDFLib.PDFDocument.load(pdfBytes);
|
|
const form = pdfDoc.getForm();
|
|
const fields = form.getFields();
|
|
const fieldList = document.getElementById('field-list');
|
|
fieldList.innerHTML = '';
|
|
|
|
fields.forEach(field => {
|
|
const type = field.constructor.name;
|
|
const name = field.getName();
|
|
const listItem = document.createElement('li');
|
|
listItem.textContent = `Field: ${name}, Type: ${type}`;
|
|
fieldList.appendChild(listItem);
|
|
});
|
|
}
|
|
|
|
// Fetch the hardcoded PDF from a URL (this can be a server-hosted or local file)
|
|
fetch('/PDF/.pdf')
|
|
.then(response => response.arrayBuffer())
|
|
.then(pdfBytes => listPdfFields(pdfBytes))
|
|
.catch(error => console.error('Error loading PDF:', error));
|
|
</script>
|
|
</body>
|
|
</html>
|