How to Resize in JavaScript DOCX Editor
28 Aug 20262 minutes to read
In this article, we are going to see how to change the height and width of the JavaScript DOCX Editor (Document Editor).
Change the Height of the DOCX Editor
The DocumentEditorContainer initially renders with a default height. You can change the height of the DocumentEditor using the height property, the value of which is in pixels.
The following example code illustrates how to change the height of the DOCX Editor.
var container = new ej.documenteditor.DocumentEditorContainer({
enableToolbar: true, height: "590px"
});
container.appendTo('#DocumentEditor');Similarly, you can also use the height property for the DocumentEditor.
Change the Width of the DOCX Editor
The DocumentEditorContainer initially renders with a default width. You can change the width of the DocumentEditor using the width property, the value of which is in percentage.
The following example code illustrates how to change the width of the DOCX Editor.
var container = new ej.documenteditor.DocumentEditorContainer({
enableToolbar: true, width: "100%"
});
container.appendTo('#DocumentEditor');Similarly, you can also use the width property for the DocumentEditor.
Resize the DOCX Editor
Using the resize method, you can change the height and width of the DOCX Editor.
The following example code illustrates how to fit the DOCX Editor to the browser window size.
var container = new ej.documenteditor.DocumentEditorContainer({ enableToolbar: true, height: '590px' });
ej.documenteditor.DocumentEditorContainer.Inject(ej.documenteditor.Toolbar);
container.serviceUrl =
'https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/';
container.created = () => {
setInterval(() => {
updateDocumentEditorSize();
}, 100);
// Adds event listener for browser window resize event.
window.addEventListener('resize', onWindowResize);
};
container.appendTo('#container');
function onWindowResize() {
// Resizes the document editor component to fit full browser window automatically whenever the browser resized.
updateDocumentEditorSize();
}
function updateDocumentEditorSize() {
// Resizes the document editor component to fit full browser window.
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
container.resize(windowWidth, windowHeight);
}The Web API hosted link
https://document.syncfusion.com/web-services/docx-editor/api/documenteditor/utilized in the DOCX Editor’s serviceUrl property is intended solely for demonstration and evaluation purposes. For production deployment, please host your own web service with your required server configurations. You can refer and reuse the GitHub Web Service example or Docker image for hosting your own web service and use for the serviceUrl property.