> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pdf.co/llms.txt
> Use this file to discover all available pages before exploring further.

# PDF to XLS

> Convert PDF to Excel(.xls) with layout and fonts preserved.

## `POST /v1/pdf/convert/to/xls`

## Attributes

<Note>Attributes are case-sensitive and should be inside JSON for POST request. for example: `{ "url": "https://example.com/file1.pdf" }`</Note>

| Attribute                              | Type                          | Required | Default                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| -------------------------------------- | ----------------------------- | -------- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `url`                                  | string                        | *Yes*    | -                          | URL to the source file [`url` attribute](/api-reference/url-input-and-request-limits#supported-file-sources)                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `callback`                             | string                        | *No*     | -                          | The callback URL (or Webhook) used to receive the POST data. see [Webhooks & Callbacks](/api-reference/webhooks). This is only applicable when `async` is set to `true`.                                                                                                                                                                                                                                                                                                                                                                                                           |
| `httpusername`                         | string                        | *No*     | -                          | HTTP auth user name if required to access source URL.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `httppassword`                         | string                        | *No*     | -                          | HTTP auth password if required to access source URL.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `pages`                                | string                        | *No*     | all pages                  | Specify page indices as comma-separated values or ranges to process (e.g. "0, 1, 2-" or "1, 2, 3-7"). The first-page index is 0. Use "!" before a number for inverted page numbers (e.g. "!0" for the last page). If not specified, the default configuration processes all pages. The input must be in string format.                                                                                                                                                                                                                                                             |
| `rect`                                 | string                        | *No*     | -                          | Defines coordinates for extraction. Use`PDF Edit Add Helper`to get or measure PDF coordinates. The format is `{x} {y} {width} {height}`.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `lang`                                 | string                        | *No*     | eng                        | Set the language for OCR (text from image) to use for scanned PDF, PNG, and JPG documents input when extracting text. see [Language Support](/api-reference/language-support). You can also use 2 languages simultaneously like this: `eng+deu` (any combination).                                                                                                                                                                                                                                                                                                                 |
| `password`                             | string                        | *No*     | -                          | Password for the PDF file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `async`                                | boolean                       | *No*     | `false`                    | Set `async` to `true` for long processes to run in the background, API will then return a `jobId` which you can use with the [Background Job Check endpoint](/api-reference/job-check). Also see [Webhooks & Callbacks](/api-reference/webhooks)                                                                                                                                                                                                                                                                                                                                   |
| `name`                                 | string                        | *No*     | -                          | File name for the generated output, the input must be in string format.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `expiration`                           | integer                       | *No*     | `60`                       | Set the expiration time for the output link in minutes. After this specified duration, any generated output file(s) will be automatically deleted from [PDF.co Temporary Files Storage](/api-reference/file-upload/overview). The maximum duration for link expiration varies based on your current subscription plan. To store permanent input files (e.g. re-usable images, pdf templates, documents) consider using [PDF.co Built-In Files Storage](https://app.pdf.co/tools/files).                                                                                            |
| `profiles`                             | object                        | *No*     | -                          | See [Profiles](/api-reference/profiles) for more information.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|     `ColumnDetectionMode`              | string                        | *No*     | Content Groups And Borders | Controls column detection/alignment in PDF table extraction. See [Column Detection Mode](#column-detection-mode) for more information.                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|     `OCRMode`                          | string                        | *No*     | Auto                       | Specifies how OCR (Optical Character Recognition) should process input content, offering various modes to tailor text extraction based on content type such as images, fonts, and vector graphics. For more information, see [OCR Extraction Modes](/api-reference/profiles#ocr-extraction-modes).                                                                                                                                                                                                                                                                                 |
|     `OCRResolution`                    | integer                       | *No*     | 300                        | Use this parameter to change the OCR resolution from the default 300 dpi. The range is from `72` to `1200` dpi.                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
|     `RotationAngle`                    | integer                       | *No*     | -                          | Use manual rotation to handle PDFs with vertically drawn text. Normally, OCR automatically detects page rotation in PDFs and extracts text accurately. However, in some cases, the PDF might not have an actual rotated page  ---  Rather, the text itself is drawn vertically. In such scenarios, auto-detection may fail. You can use this parameter to manually set the page rotation. The available angles are: `0`, `1`, `2`, `3`.                                                                                                                                            |
|     `LineGroupingMode`                 | string                        | *No*     | None                       | Controls line grouping in PDF text extraction. Modes: `None` (no grouping), `GroupByRows` (merge rows if all cells align), `GroupByColumns` (merge cells by column), `JoinOrphanedRows` (merge single-cell rows to above if no separator).                                                                                                                                                                                                                                                                                                                                         |
|     `ConsiderFontColors`               | boolean                       | *No*     | `false`                    | Controls whether font colors should be considered when detecting table structure and merging text objects during PDF extraction. Set to true to consider font colors.                                                                                                                                                                                                                                                                                                                                                                                                              |
|     `DetectNewColumnBySpacesRatio`     | string                        | *No*     | 1.2                        | Controls how spaces between words are interpreted for column detection in PDF text extraction. It defines the ratio of space width that determines when text should be treated as being in separate columns.                                                                                                                                                                                                                                                                                                                                                                       |
|     `AutoAlignColumnsToHeader`         | boolean                       | *No*     | `true`                     | Controls how columns are detected and aligned during table extraction from PDF documents. It affects both table structure detection and text extraction with formatting preservation. Set to true to automatically align columns to the header row. When set to true (default), the row with the most columns is used as the header, and all other rows are aligned to this structure --- ideal for well-structured tables. When set to false, columns are analyzed independently across all rows to build the structure, which works better for inconsistent or irregular tables. |
|     `OCRImagePreprocessingFilters`     | object                        | *No*     | -                          | Image preprocessing filters for OCR. Refer to [OCRImagePreprocessingFilters](#ocrimagepreprocessingfilters) for usage examples.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
|         `.AddGrayscale`                | boolean                       | *No*     | `false`                    | Converts to grayscale before OCR.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
|         `.AddGammaCorrection`          | array\[string (float format)] | *No*     | \["1.4"]                   | Adds a gamma correction filter.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
|     `OCRAutoModeMinExistingTextLength` | integer                       | *No*     | `8`                        | The minimum number of characters a page must have to skip OCR. If a page has fewer, OCR will run. For example, if set to 8, OCR is skipped on pages with more than 8 characters.                                                                                                                                                                                                                                                                                                                                                                                                   |
|     `SaveVectors`                      | boolean                       | *No*     | `false`                    | Controls whether to save vector graphics during PDF to HTML conversion. Set to true to save vector graphics.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|     `SaveImages`                       | string                        | *No*     | None                       | Controls how images are saved during PDF to HTML conversion. Modes: `None` (no images), `OuterFile` (save to sub-folder), `Embed` (embed as Base64 data:URI).                                                                                                                                                                                                                                                                                                                                                                                                                      |
|     `ConsiderFontSizes`                | boolean                       | *No*     | `false`                    | Set to true to this parameter makes the converter consider font size differences in document text when detecting and parsing table structures. This can be helpful in cases where tables are formatted using different font sizes to distinguish between headers, data cells, or other structural elements.                                                                                                                                                                                                                                                                        |
|     `ExtractionArea`                   | array\[numbe]                 | *No*     | -                          | Extract text in a specific area by defining the extraction area - set with points in the format \[x, y, width, height].                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|     `ExtractShadowLikeText`            | boolean                       | *No*     | `true`                     | Controls whether to extract invisible text from a PDF document. Set to false to skip over invisible text during extraction. This is particularly useful when dealing with PDFs that contain hidden text layers or when you only want to extract visible content. When this value is set to false, OCRMode must be set to `Auto` to properly apply the shadow text filtering effect.                                                                                                                                                                                                |
|     `DataEncryptionAlgorithm`          | string                        | *No*     | -                          | Controls the encryption algorithm used for data encryption. See [User-Controlled Encryption](/knowledgebase/user-controlled-encryption) for more information. The available algorithms are: `AES128`, `AES192`, `AES256`.                                                                                                                                                                                                                                                                                                                                                          |
|     `DataEncryptionKey`                | string                        | *No*     | -                          | Controls the encryption key used for data encryption. See [User-Controlled Encryption](/knowledgebase/user-controlled-encryption) for more information.                                                                                                                                                                                                                                                                                                                                                                                                                            |
|     `DataEncryptionIV`                 | string                        | *No*     | -                          | Controls the encryption IV used for data encryption. See [User-Controlled Encryption](/knowledgebase/user-controlled-encryption) for more information.                                                                                                                                                                                                                                                                                                                                                                                                                             |
|     `DataDecryptionAlgorithm`          | string                        | *No*     | -                          | Controls the decryption algorithm used for data decryption. See [User-Controlled Encryption](/knowledgebase/user-controlled-encryption) for more information. The available algorithms are: `AES128`, `AES192`, `AES256`.                                                                                                                                                                                                                                                                                                                                                          |
|     `DataDecryptionKey`                | string                        | *No*     | -                          | Controls the decryption key used for data decryption. See [User-Controlled Encryption](/knowledgebase/user-controlled-encryption) for more information.                                                                                                                                                                                                                                                                                                                                                                                                                            |
|     `DataDecryptionIV`                 | string                        | *No*     | -                          | Controls the decryption IV used for data decryption. See [User-Controlled Encryption](/knowledgebase/user-controlled-encryption) for more information.                                                                                                                                                                                                                                                                                                                                                                                                                             |

<Note>You can use [profiles](/api-reference/profiles#converting-pdfs) to control the convert process and output of the CSV file.</Note>

### Column Detection Mode

This might be case when a document contains a number of overlapping invisible text and vector objects that affect column detection. In this case you may need to fix the wrongly positioned data.

Set the options for your column detection via the following `profiles` parameters:

`ColumnDetectionMode` - available values:

* `ContentGroupsAndBorders` (default, no need to specify)
* `ContentGroups`
* `Borders`
* `BorderedTables`
* `ContentGroupsAI`

```json theme={null}
{
 "profiles": "{ 'ColumnDetectionMode': 'ContentGroups' }"
}
```

### `OCRImagePreprocessingFilters`

To set image preprocessing filters, please use:

```json theme={null}
{
 "profiles": "{
    "ExtractShadowLikeText": false,
    "OCRMode": "Auto",
    "OCRImagePreprocessingFilters.AddGrayscale()": [],
    "OCRImagePreprocessingFilters.AddGammaCorrection()": [
        1.4
    ]
}"
}
```

## Query parameters

*No query parameters accepted.*

## Responses

| Parameter             | Type    | Description                                                                                                                  |
| --------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `url`                 | string  | Direct URL to the final PDF file stored in S3.                                                                               |
| `outputLinkValidTill` | string  | Timestamp indicating when the output link will expire                                                                        |
| `pageCount`           | integer | Number of pages in the PDF document.                                                                                         |
| `error`               | boolean | Indicates whether an error occurred (`false` means success)                                                                  |
| `status`              | string  | Status code of the request (200, 404, 500, etc.). For more information, see [Response Codes](/api-reference/response-codes). |
| `name`                | string  | Name of the output file                                                                                                      |
| `credits`             | integer | Number of credits consumed by the request                                                                                    |
| `remainingCredits`    | integer | Number of credits remaining in the account                                                                                   |
| `duration`            | integer | Time taken for the operation in milliseconds                                                                                 |

## `Example` Payload

<Note>To see the request size limits, please refer to the [Request Size Limits](/api-reference/url-input-and-request-limits#pdf-co-request-size).</Note>

```json theme={null}
{
  "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-excel/sample.pdf",
  "async": false
}
```

## `Example` Response

<Note>To see the main response codes, please refer to the [Response Codes](/api-reference/response-codes) page.</Note>

```json theme={null}
{
  "url": "https://pdf-temp-files.s3.amazonaws.com/60c6b9f50280495a9567f73a0a394252/sample.xlsx",
  "pageCount": 1,
  "error": false,
  "status": 200,
  "name": "sample.xlsx",
  "remainingCredits": 60568
}
```

<Note>
  **Inconsistent URL Encoding in cURL Output:** When using cURL to make API requests, the output JSON may show URL characters encoded as Unicode escape sequences. For example, the ampersand character (`&`) may appear as `\u0026` in the cURL output. This is normal JSON encoding behavior and does not affect the validity of the URL. The URL will function correctly when used, as JSON parsers automatically decode these escape sequences. If you're parsing the response programmatically, your JSON parser will handle this conversion automatically.
</Note>

## Code Samples

<Tabs>
  <Tab title="JavaScript/Node.js">
    ```javascript theme={null}
    var https = require("https");
      var path = require("path");
      var fs = require("fs");


      // The authentication key (API Key).
      // Get your own by registering at https://app.pdf.co
      const API_KEY = "***********************************";


      // Direct URL of source PDF file.
      // You can also upload your own file into PDF.co and use it as url. Check "Upload File" samples for code snippets: https://github.com/bytescout/pdf-co-api-samples/tree/master/File%20Upload/    
      const SourceFileUrl = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-to-excel/sample.pdf";
      // Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'.
      const Pages = "";
      // PDF document password. Leave empty for unprotected documents.
      const Password = "";
      // Destination XLS file name
      const DestinationFile = "./result.xls";


      // Prepare request to `PDF To XLS` API endpoint
      var queryPath = `/v1/pdf/convert/to/xls`;

      // JSON payload for api request
      var jsonPayload = JSON.stringify({
          name: path.basename(DestinationFile), password: Password, pages: Pages, url: SourceFileUrl
      });

      var reqOptions = {
          host: "api.pdf.co",
          method: "POST",
          path: queryPath,
          headers: {
              "x-api-key": API_KEY,
              "Content-Type": "application/json",
              "Content-Length": Buffer.byteLength(jsonPayload, 'utf8')
          }
      };
      // Send request
      var postRequest = https.request(reqOptions, (response) => {
          response.on("data", (d) => {
              // Parse JSON response
              var data = JSON.parse(d);
              if (data.error == false) {
                  // Download XLS file
                  var file = fs.createWriteStream(DestinationFile);
                  https.get(data.url, (response2) => {
                      response2.pipe(file)
                          .on("close", () => {
                              console.log(`Generated XLS file saved as "${DestinationFile}" file.`);
                          });
                  });
              }
              else {
                  // Service reported error
                  console.log(data.message);
              }
          });
      }).on("error", (e) => {
          // Request error
          console.log(e);
      });

      // Write request data
      postRequest.write(jsonPayload);
      postRequest.end();
    ```
  </Tab>

  <Tab title="C#">
    ```csharp theme={null}
    using System;
      using System.Collections.Generic;
      using System.IO;
      using System.Net;
      using Newtonsoft.Json;
      using Newtonsoft.Json.Linq;

      namespace PDFcoApiExample
      {
          class Program
          {
              // The authentication key (API Key).
              // Get your own by registering at https://app.pdf.co
              const String API_KEY = "***********************************";
              
              // Direct URL of source PDF file.
              // You can also upload your own file into PDF.co and use it as url. Check "Upload File" samples for code snippets: https://github.com/bytescout/pdf-co-api-samples/tree/master/File%20Upload/
              const string SourceFileUrl = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-to-excel/sample.pdf";
              // Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'.
              const string Pages = "";
              // PDF document password. Leave empty for unprotected documents.
              const string Password = "";
              // Destination XLS file name
              const string DestinationFile = @".\result.xls";

              static void Main(string[] args)
              {
                  // Create standard .NET web client instance
                  WebClient webClient = new WebClient();

                  // Set API Key
                  webClient.Headers.Add("x-api-key", API_KEY);

                  // URL for `PDF To XLS` API call
                  string url = "https://api.pdf.co/v1/pdf/convert/to/xls";

                  // Prepare requests params as JSON
                  Dictionary<string, object> parameters = new Dictionary<string, object>();
                  parameters.Add("name", Path.GetFileName(DestinationFile));
                  parameters.Add("password", Password);
                  parameters.Add("pages", Pages);
                  parameters.Add("url", SourceFileUrl);

                  // Convert dictionary of params to JSON
                  string jsonPayload = JsonConvert.SerializeObject(parameters);

                  try
                  {
                      // Execute POST request with JSON payload
                      string response = webClient.UploadString(url, jsonPayload);

                      // Parse JSON response
                      JObject json = JObject.Parse(response);

                      if (json["error"].ToObject<bool>() == false)
                      {
                          // Get URL of generated XLS file
                          string resultFileUrl = json["url"].ToString();

                          // Download XLS file
                          webClient.DownloadFile(resultFileUrl, DestinationFile);

                          Console.WriteLine("Generated XLS file saved as \"{0}\" file.", DestinationFile);
                      }
                      else
                      {
                          Console.WriteLine(json["message"].ToString());
                      }
                  }
                  catch (WebException e)
                  {
                      Console.WriteLine(e.ToString());
                  }

                  webClient.Dispose();

                  Console.WriteLine();
                  Console.WriteLine("Press any key...");
                  Console.ReadKey();
              }
          }
      }
    ```
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    package com.company;

      import com.google.gson.JsonObject;
      import com.google.gson.JsonParser;
      import okhttp3.*;

      import java.io.*;
      import java.net.*;
      import java.nio.file.Path;
      import java.nio.file.Paths;

      public class Main
      {
          // The authentication key (API Key).
          // Get your own by registering at https://app.pdf.co
          final static String API_KEY = "***********************************";

          // Direct URL of source PDF file.
          // You can also upload your own file into PDF.co and use it as url. Check "Upload File" samples for code snippets: https://github.com/bytescout/pdf-co-api-samples/tree/master/File%20Upload/    
          final static String SourceFileUrl = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/pdf-to-excel/sample.pdf";
          // Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'.
          final static String Pages = "";
          // PDF document password. Leave empty for unprotected documents.
          final static String Password = "";
          // Destination XLS file name
          final static Path DestinationFile = Paths.get(".\\result.xls");


          public static void main(String[] args) throws IOException
          {
              // Create HTTP client instance
              OkHttpClient webClient = new OkHttpClient();

              // Prepare URL for `PDF To XLS` API call
              String query = "https://api.pdf.co/v1/pdf/convert/to/xls";

              // Make correctly escaped (encoded) URL
              URL url = null;
              try
              {
                  url = new URI(null, query, null).toURL();
              }
              catch (URISyntaxException e)
              {
                  e.printStackTrace();
              }

              // Create JSON payload
              String jsonPayload = String.format("{\"name\": \"%s\", \"password\": \"%s\", \"pages\": \"%s\", \"url\": \"%s\"}",
                      DestinationFile.getFileName(),
                      Password,
                      Pages,
                      SourceFileUrl);

              // Prepare request body
              RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonPayload);
              
              // Prepare request
              Request request = new Request.Builder()
                  .url(url)
                  .addHeader("x-api-key", API_KEY) // (!) Set API Key
                  .addHeader("Content-Type", "application/json")
                  .post(body)
                  .build();
              
              // Execute request
              Response response = webClient.newCall(request).execute();

              if (response.code() == 200)
              {
                  // Parse JSON response
                  JsonObject json = new JsonParser().parse(response.body().string()).getAsJsonObject();

                  boolean error = json.get("error").getAsBoolean();
                  if (!error)
                  {
                      // Get URL of generated XLS file
                      String resultFileUrl = json.get("url").getAsString();

                      // Download XLS file
                      downloadFile(webClient, resultFileUrl, DestinationFile.toFile());

                      System.out.printf("Generated XLS file saved as \"%s\" file.", DestinationFile.toString());
                  }
                  else
                  {
                      // Display service reported error
                      System.out.println(json.get("message").getAsString());
                  }
              }
              else
              {
                  // Display request error
                  System.out.println(response.code() + " " + response.message());
              }
          }

          public static void downloadFile(OkHttpClient webClient, String url, File destinationFile) throws IOException
          {
              // Prepare request
              Request request = new Request.Builder()
                      .url(url)
                      .build();
              // Execute request
              Response response = webClient.newCall(request).execute();

              byte[] fileBytes = response.body().bytes();

              // Save downloaded bytes to file
              OutputStream output = new FileOutputStream(destinationFile);
              output.write(fileBytes);
              output.flush();
              output.close();

              response.close();
          }
      }


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>PDF To Excel Extraction Results</title>
    </head>
    <body>

    <?php 
    // Note: If you have input files large than 200kb we highly recommend to check "async" mode example.

    // Get submitted form data
    $apiKey = $_POST["apiKey"]; // The authentication key (API Key). Get your own by registering at https://app.pdf.co
    $pages = $_POST["pages"];


    // 1. RETRIEVE THE PRESIGNED URL TO UPLOAD THE FILE.
    // * If you already have the direct PDF file link, go to the step 3.

    // Create URL
    $url = "https://api.pdf.co/v1/file/upload/get-presigned-url" . 
        "?name=" . urlencode($_FILES["file"]["name"]) .
        "&contenttype=application/octet-stream";
        
    // Create request
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_HTTPHEADER, array("x-api-key: " . $apiKey));
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    // Execute request
    $result = curl_exec($curl);

    if (curl_errno($curl) == 0)
    {
        $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        
        if ($status_code == 200)
        {
            $json = json_decode($result, true);
            
            // Get URL to use for the file upload
            $uploadFileUrl = $json["presignedUrl"];
            // Get URL of uploaded file to use with later API calls
            $uploadedFileUrl = $json["url"];
            
            // 2. UPLOAD THE FILE TO CLOUD.
            //echo json_encode($_FILES["file"]);
            //print_r($_FILES["file"]);
            $localFile = $_FILES["file"]["tmp_name"];
            $fileHandle = fopen($localFile, "r");
            
            curl_setopt($curl, CURLOPT_URL, $uploadFileUrl);
            curl_setopt($curl, CURLOPT_HTTPHEADER, array("content-type: application/octet-stream"));
            curl_setopt($curl, CURLOPT_PUT, true);
            curl_setopt($curl, CURLOPT_INFILE, $fileHandle);
            curl_setopt($curl, CURLOPT_INFILESIZE, filesize($localFile));

            // Execute request
            curl_exec($curl);
            
            fclose($fileHandle);
            
            if (curl_errno($curl) == 0)
            {
                $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
                
                if ($status_code == 200)
                {
                    // 3. CONVERT UPLOADED PDF FILE TO Excel
                    
                    ExtractExcel($apiKey, $uploadedFileUrl, $pages);
                }
                else
                {
                    // Display request error
                    echo "<p>Status code: " . $status_code . "</p>"; 
                    echo "<p>" . $result . "</p>"; 
                }
            }
            else
            {
                // Display CURL error
                echo "Error: " . curl_error($curl);
            }
        }
        else
        {
            // Display service reported error
            echo "<p>Status code: " . $status_code . "</p>"; 
            echo "<p>" . $result . "</p>"; 
        }
        
        curl_close($curl);
    }
    else
    {
        // Display CURL error
        echo "Error: " . curl_error($curl);
    }

    function ExtractExcel($apiKey, $uploadedFileUrl, $pages) 
    {
        // Create URL
        $url = "https://api.pdf.co/v1/pdf/convert/to/xlsx";
        // (!) If you need the old XLS format use `https://api.pdf.co/v1/pdf/convert/to/xls` endpoint,
        
        // Prepare requests params
        $parameters = array();
        $parameters["url"] = $uploadedFileUrl;
        $parameters["pages"] = $pages;
    $parameters["async"] = true;  // (!) Make asynchronous job

        // Create Json payload
        $data = json_encode($parameters);

        // Create request
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_HTTPHEADER, array("x-api-key: " . $apiKey, "Content-type: application/json"));
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

        // Execute request
        $result = curl_exec($curl);
        
        if (curl_errno($curl) == 0)
        {
            $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            
            if ($status_code == 200)
            {
                $json = json_decode($result, true);
                
                if (!isset($json["error"]) || $json["error"] == false)
                {
                  // URL of generated XLSX file that will available after the job completion
                  $resultFileUrl = $json["url"];
                  // Asynchronous job ID
                  $jobId = $json["jobId"];
                
                  // Check the job status in a loop
                  do
                  {
                      $status = CheckJobStatus($jobId, $apiKey); // Possible statuses: "working", "failed", "aborted", "success".
                    
                      // Display timestamp and status (for demo purposes)
                      echo "<p>" . date(DATE_RFC2822) . ": " . $status . "</p>";
                    
                      if ($status == "success")
                      {
                          // Display link to the file with conversion results
                          echo "<div><h2>Conversion Result:</h2><a href='" . $resultFileUrl . "' target='_blank'>" . $resultFileUrl . "</a></div>";
                          break;
                      }
                      else if ($status == "working")
                      {
                          // Pause for a few seconds
                          sleep(3);
                      }
                      else 
                      {
                          echo $status . "<br/>";
                          break;
                      }
                  }
                  while (true);
                }
                else
                {
                    // Display service reported error
                    echo "<p>Error: " . $json["message"] . "</p>"; 
                }
            }
            else
            {
                // Display request error
                echo "<p>Status code: " . $status_code . "</p>"; 
                echo "<p>" . $result . "</p>"; 
            }
        }
        else
        {
            // Display CURL error
            echo "Error: " . curl_error($curl);
        }
        
        // Cleanup
        curl_close($curl);
    }

    function CheckJobStatus($jobId, $apiKey)
    {
        $status = null;
        
      // Create URL
        $url = "https://api.pdf.co/v1/job/check";
        
        // Prepare requests params
        $parameters = array();
        $parameters["jobid"] = $jobId;

        // Create Json payload
        $data = json_encode($parameters);

        // Create request
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_HTTPHEADER, array("x-api-key: " . $apiKey, "Content-type: application/json"));
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        
        // Execute request
        $result = curl_exec($curl);
        
        if (curl_errno($curl) == 0)
        {
            $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
            
            if ($status_code == 200)
            {
                $json = json_decode($result, true);
            
                if (!isset($json["error"]) || $json["error"] == false)
                {
                    $status = $json["status"];
                }
                else
                {
                    // Display service reported error
                    echo "<p>Error: " . $json["message"] . "</p>"; 
                }
            }
            else
            {
                // Display request error
                echo "<p>Status code: " . $status_code . "</p>"; 
                echo "<p>" . $result . "</p>"; 
            }
        }
        else
        {
            // Display CURL error
            echo "Error: " . curl_error($curl);
        }
        
        // Cleanup
        curl_close($curl);
        
        return $status;
    }

    ?>

    </body>
    </html>
    ```
  </Tab>
</Tabs>
