How to Remove an Object from a DOCX Document in PHP

DOCX is a popular format with businesses worldwide due its easy versatility and design functions. However, manipulating and editing an online DOCX file can be a difficult process if attempted manually. To simplify the modification process and improve the user experience, we offer several document editing APIs that can be used in conjunction. The following API utilizes the editing URL that is created by the Begin Editing function, and will require the path of the object you need to remove.

Image for post
Image for post

First, we will need to install the SDK:

composer require cloudmersive/cloudmersive_document_convert_api_client

Next, we will plug in the editing URL and object path, and call the function with the following code:

require_once(__DIR__ . '/vendor/autoload.php');

The returned response will indicate if the task was successful and will also provide and updated document URL. If you need to perform further editing functions, then you would continue on your modification path from here. However, if you are finished editing, you can use the Finish Editing API to download your updated result.

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store