How to convert fillable PDF forms to HTML forms using PHP
These steps demonstrate how to convert PDF forms to HTML using the FormVu cloud API. You can utilize:
- The IDR Solutions trial and cloud subscription service
- Your own self-hosted FormVu microservice
Using composer you will install the idrsolutions-php-client package with the following command:
composer require idrsolutions/idrsolutions-php-client
Here is a basic code example to convert PDF forms to HTML. You can find configuration options and advanced features below.
‘Token’, // Required only when connecting to the IDRsolutions trial and cloud subscription service
‘input’ => IDRCloudClient::INPUT_UPLOAD,
‘file’ => __DIR__ . ‘path/to/file.pdf’
);
$results = IDRCloudClient::convert(array(
‘endpoint’ => $endpoint,
‘parameters’ => $parameters
));
IDRCloudClient::downloadOutput($results, __DIR__ . ‘/’);
echo $results[‘downloadUrl’];
Return result to a callback url
The FormVu Microservice supports a callback URL to notify you of the conversion status upon completion. This eliminates the need to poll the service to check if the conversion is done.
You can include the callback URL in the parameters array as demonstrated below:
$parameters = array(
//’token’ => ‘Token’, // Required only when connecting to the IDRsolutions trial and cloud subscription service
‘input’ => IDRCloudClient::INPUT_UPLOAD,
‘callbackUrl’ => ‘http://listener.url’,
‘file’ => __DIR__ . ‘path/to/file.pdf’
);
Configuration Options
The FormVu API accepts a stringified JSON object with key-value pair configuration options to customize your conversion. Add these settings to the parameters array. You can find a complete list of configuration options for converting PDF forms to HTML here.
‘settings’ => ‘{"key":"value","key":"value"}’
Upload by URL
In addition to uploading a local file, you can provide a URL for the FormVu Microservice to download and convert. To do this, replace the input and file values in the parameters array with the following:
‘input’ => IDRCloudClient.DOWNLOAD
‘url’ => ‘http://exampleURL/exampleFile.pdf’
Using Authentication
If your FormVu Microservice deployment requires a username and password for converting PDF forms to HTML, you must include these credentials with each conversion. Add the variables username and password to the parameters array as shown below:
‘username’ => ‘Username_If_Required’,
‘password’ => ‘Password_If_Required’,
If this is the case you will also need to provide the authentication values to the downloadOutput method as well.
IDRCloudClient::downloadOutput($results, __DIR__ . ‘/’,’newFileName’,’username’,’password’);
You can read our article to understand the PDF format and if you’re looking for meanings of common PDF terms, we recommend you check out our PDF glossary.