How to Begin Editing a Document in PHP

Navigating the editing of an online document can be a messy business; the inner nuances of the various formats can make manual modifications both slow and difficult. However, if you leverage our portfolio of document editing APIs, it can significantly simplify your task. The Begin Editing API is the first step in the editing process, and the focus of this tutorial. With this tool you can upload your document and create an editing URL that can be used for modifying the file.

To initiate our process, we will run this command to install the SDK:

composer require cloudmersive/cloudmersive_document_convert_api_client

Next, we will call the Begin Editing function with the following code:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: Apikey
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');
$apiInstance = new Swagger\Client\Api\EditDocumentApi(


new GuzzleHttp\Client(),
$config
);
$input_file = "/path/to/inputfile"; // \SplFileObject | Input file to perform the operation on.
try {
$result = $apiInstance->editDocumentBeginEditing($input_file);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling EditDocumentApi->editDocumentBeginEditing: ', $e->getMessage(), PHP_EOL;
}
?>

This will return the aforementioned URL and open up the document for any editing functions you need to perform. To retrieve your free API key and gain access to this and other editing APIs, simply head to the Cloudmersive website to register for your free account.

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