Editing
Text and Image Editing - Sample Code
Edit PDF text and images using this JavaScript sample (no servers or other external dependencies required). This sample allows text and images to be edited, moved and deleted from a PDF.This sample works on all browsers and mobile devices without using plug-ins. Learn more about our Web SDK.
// eslint-disable-next-line no-undef
const WebViewerConstructor = isWebComponent() ? WebViewer.WebComponent : WebViewer;
WebViewerConstructor(
{
path: '../../../lib',
initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf',
enableFilePicker: true,
},
document.getElementById('viewer')
).then(instance => {
samplesSetup(instance);
instance.UI.enableFeatures([instance.UI.Feature.ContentEdit]);
instance.UI.setToolbarGroup(instance.UI.ToolbarGroup.EDIT_TEXT);
document.getElementById('file-picker').onchange = e => {
const file = e.target.files[0];
if (file) {
instance.UI.loadDocument(file);
}
};
document.getElementById('url-form').onsubmit = e => {
e.preventDefault();
instance.UI.loadDocument(document.getElementById('url').value);
};
});