WebViewer is a JavaScript-based PDF SDK for building document functionality in web apps.

Capabilities

card-icon

Office Template Generation

Securely merge JSON data with MS Word, PowerPoint and Excel templates directly in the browser - no server required!

Read more about our Dynamic Document Generation here.

Code snippet


WebViewer(...)
.then(instance = > {

	const { documentViewer } = instance.Core;
	documentViewer.on('documentLoaded', () = > {
		const doc = documentViewer.getDocument();

		// it is possible to extract document template keys in WebViewer
		const keys = doc.getTemplateKeys();

		// create an options object and add your template
		// replacement values to it, keeping in mind the formats for text, images and dynamic table insertion
		const options = {};
		for (const i in keys) {
			options[keys[i]] = json_data_string;
		}

		// apply the template values to the currently loaded document in WebViewer
		await documentViewer.getDocument().applyTemplateValues(options);
	});
});