xinyu zhang Xinyu is a member of the web development, support, and marketing team at IDRsolutions.

How to convert PDF to HTML in PHP

1 min read

PDF forms to HTML forms using Java (Icon)

PDF to HTML using Java (Icon)

In this article I will show you how you can use our PDF files to HTML API to convert documents to HTML with our library BuildVu. BuildVu is the best PDF to HTML conversion tool for developers. PDF to HTML conversion helps you to optimise your PDF content for display on browsers. We have a separate article explaining the benefits of converting PDF to HTML.

Convert PDF to HTML using PHP

Although the services can be accessed with standard HTTP requests, this tutorial uses our open-source PHP IDRCloudClient, which offers a straightforward PHP wrapper for the REST API.

Prerequisites

To install the idrsolutions-php-client package using Composer, execute the following command:

Code Examples

Here is a basic code example demonstrating how to generate HTML from PDF. Configuration options and advanced features are detailed below:

Return result to a callback url

The BuildVu Microservice supports a callback URL to send the status upon conversion completion, eliminating the need to constantly poll the service. You can provide the callback URL to the parameters array as demonstrated below:

Configuration Options

The BuildVu API allows for conversion customization using a stringified JSON object with key-value pair configuration options. Add these settings to the parameters array. A comprehensive list of options for converting PDF files to HTML or SVG can be found here.

Upload by URL

In addition to uploading a local file, you can provide a URL for the BuildVu Microservice to download and convert. Simply replace the input and file values in the parameters array with the following.

Using Authentication

If you require authentication for your BuildVu Microservice, provide username and password when converting and downloading HTML from PDF. Add two variables named username and password to the parameters array, as shown below.

In such cases, you’ll also need to provide the authentication values to the downloadOutput method.



BuildVu allows you to

View PDF files in a Web app
Convert PDF documents to HTML5
Parse PDF documents as HTML
xinyu zhang Xinyu is a member of the web development, support, and marketing team at IDRsolutions.