Sales Order PDF to Excel in PHP using PDF.co Web API

Nov 20, 2024·3 Minutes Read

In this tutorial, we’ll walk you through the steps to convert a sales order PDF into Excel format using the PDF.co Web API with PHP. We will use a sample sales order as an example to demonstrate the process.

Sample Sales Order
Sample Sales Order

Step 1: Copy and Review the Source Code

  • Begin by copying the provided HTML and PHP source code.
  • Paste this code into your preferred code editor, such as VS Code, Sublime Text, or PHPStorm

For larger files, enable asynchronous processing. This allows the job to run in the background and track progress without timeouts. Refer to PDF.co's documentation for more details on asynchronous jobs.

Step 2: Save the PHP and HTML File in the Directory

Once you've edited the code, save the PHP and HTML file in the appropriate directory for local hosting.

  • For XAMPP Users: Save the file in the /htdocs directory.
  • For WampServer Users: Save the file in the /www directory.

Saving the file in these locations ensures that it’s accessible from your local server.

Save the PHP and HTML File in the Directory

Step 3: Start the Apache Module

To execute your PHP script, ensure that your Apache server is running.

  • Open theXAMPP or WampServer control panel.
  • Click Start next to the Apache module to activate the server.
XAMPP Control Panel

Step 4: Run the PHP Program Locally

Open your browser and enter the following in the address bar to access the file:

  • URL Path: If you saved the file as sample.html in a folder, enter localhost/your-folder-name/sample.html.
  • Add Your API Key: Log in to your PDF.co account and retrieve your API Key from your dashboard.
  • Input Your PDF File: Upload the PDF file you want to convert to Excel.
  • Specify the Page Index (Optional): Enter the page number you want to convert or leave it blank to process all pages.
  • Send the Request: Click the Proceed button to send the request to the PDF.co Web API for conversion.
Run the PHP Program Locally

Step 5: Access the Generated Excel Result

Once the process completes, a link to the output file will be provided. Click on this link to download the converted Excel file.

Access the Generated Excel Result

Step 6: Generated Excel Output

Open the downloaded Excel file to view the results.

Generated Excel Output
Generated Excel Output

In this tutorial, you learned how to convert a sales order into XLS using PHP. You learned how to set up the code samples to get the XLS output. You also learned how to use the PDF.co Web API to convert PDF files into XLS format.

Related Tutorials

See Related Tutorials