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. FormVu is the best tool for filling PDF forms in HTML. 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.
<?php
require_once __DIR__ . "/PATH/TO/vendor/autoload.php";
use IDRsolutions\IDRCloudClient;
$endpoint = "https://cloud.idrsolutions.com/cloud/" . IDRCloudClient::INPUT_FORMVU;
$parameters = array(
//’token’ => ‘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’];
Adjust the `$endpoint` to your hosted URL if you are self-hosting.
Get a notification once the conversion is finished
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’
Once converted, you can download the results from `downloadUrl`. You’ll find the output HTML in the folder (specified by the `output` variable). Opening form.html will allow you to view the prior fillable PDF form in HTML form output! You’re then free to parse/edit/host the content as you see fit.
Read our other articles to understand the PDF format, and if you’re looking for meanings of common PDF terms, we recommend you check out our PDF glossary.
FormVu allows you to
Use Interactive PDF Forms in the Web Browser |
Integrate fillable PDF Forms into Web Apps |
Parse PDF forms as HTML5 |
What is FormVu?
FormVu is a commercial SDK for converting PDF Form files into standalone HTML with interactive form components.
Why use FormVu?
FormVu allows you to integrate PDF forms into your web application effortlessly while retaining all their interaction and functionality.
What licenses are available?
We have 3 licenses available:
Cloud for form conversion using the shared IDRsolutions cloud server, Self hosted server option for your own cloud or on-premise servers, and Enterprise for more demanding requirements.
How to use FormVu?
Want to learn more about FormVu and how to use it, we have plenty of tutorials and guides to help you.