> ## 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.

# Barcodes Reader

> Read barcodes from images and **PDF**. Can read all popular barcode types from QR Code and Code 128, EAN to Datamatrix, PDF417, GS1 and many other barcodes.

## `POST /v1/barcode/read/from/url`

## 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. |
| `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)                                                                       |
| `type`                        | string  | *Yes*    | QRCode    | Set the barcode type to be used. See available barcode types in the [Supported Barcode Types](/api-reference/barcode/overview#supported-barcode-types)                                                                                                                                                                 |
| `types`                       | string  | *No*     | -         | Detects checkboxes, radiobuttons, vertical and horizontal lines, and general segments (all content types) on scanned documents using the barcode reader engine. Comma-separated list of object types to decode, must be in a string format.                                                                            |
| `profiles`                    | object  | *No*     | -         | See [Profiles](/api-reference/profiles) for more information.                                                                                                                                                                                                                                                          |
|     `RenderingResolution`     | integer | *No*     | 120       | Set the rendering resolution for the barcode reader engine. The default resolution is 120 DPI.                                                                                                                                                                                                                         |
|     `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.                                                                                                                                                                 |

## Query parameters

*No query parameters accepted.*

## Responses

| Parameter          | Type           | Description                                                                                                                  |
| ------------------ | -------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `barcodes`         | array\[object] | List of barcodes found in the document                                                                                       |
| `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). |
| `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                                                                                 |

### types

Detects checkboxes, radiobuttons, vertical and horizontal lines, and general segments (all content types) on scanned documents using the barcode reader engine.

Comma-separated list of object types to decode, must be in a string format.

## Visual Element Detection Modes

* Checkbox: Locates check boxes.
* Segment: Locates and selects objects on a page (general selection).
* UnderlinedField: Detects fillable fields (typically, underlined spaces, i.e. fields to fill in a form).
* Rectangle: Detects rectangles, including checkboxes. Also returns the value as 1 if a checkmark or a filled rectangle was detected.
* Oval: Detects rounded or oval marks (typically, a radiobutton). Returns value of 1 if filled out radiobutton was detected.
* HorizontalLine: Detects horizontal lines.
* VerticalLine: Detects vertical lines.

## Normal Example

## `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-html/sample.pdf",
  "types": "Checkbox,UnderlinedField",
  "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}
{
  "barcodes": [
    {
      "Value": "abcdef123456",
      "RawData": "",
      "Type": 14,
      "Rect": "{X=448,Y=23,Width=106,Height=112}",
      "Page": 0,
      "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
      "Confidence": 1,
      "Metadata": "",
      "TypeName": "QRCode"
    },
    {
      "Value": "test123",
      "RawData": "",
      "Type": 2,
      "Rect": "{X=111,Y=60,Width=255,Height=37}",
      "Page": 0,
      "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
      "Confidence": 0.90625155,
      "Metadata": "",
      "TypeName": "Code128"
    },
    {
      "Value": "123456",
      "RawData": "",
      "Type": 4,
      "Rect": "{X=111,Y=129,Width=306,Height=37}",
      "Page": 0,
      "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
      "Confidence": 0.7710818,
      "Metadata": "",
      "TypeName": "Code39"
    },
    {
      "Value": "<FNC1>0112345678901231",
      "RawData": "",
      "Type": 2,
      "Rect": "{X=111,Y=198,Width=305,Height=37}",
      "Page": 0,
      "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
      "Confidence": 0.9156459,
      "Metadata": "",
      "TypeName": "Code128"
    },
    {
      "Value": "12345670",
      "RawData": [
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        0
      ],
      "Type": 5,
      "Rect": "{X=111,Y=267,Width=182,Height=0}",
      "Page": 0,
      "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
      "Confidence": 1,
      "Metadata": "",
      "TypeName": "I2of5"
    },
    {
      "Value": "1234567890128",
      "RawData": "",
      "Type": 6,
      "Rect": "{X=102,Y=336,Width=71,Height=72}",
      "Page": 0,
      "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
      "Confidence": 0.895925164,
      "Metadata": "",
      "TypeName": "EAN13"
    }
  ],
  "pageCount": 1,
  "error": false,
  "status": 200,
  "remainingCredits": 99826192,
  "credits": 35
}
```

#### `Example` CURL

```bash theme={null}
curl --location --request POST 'https://api.pdf.co/v1/barcode/read/from/url' \
--header 'x-api-key: *******************' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/barcode-reader/sample.pdf",
"types": "QRCode,Code128,Code39,Interleaved2of5,EAN13",
"pages": "0",
"async": false
}'
```

## Optical Marks Reader

Our barcode reader engine can also find the following marks and objects on scanned documents:

* Checkboxes
* Radioboxes
* Vertical and horizontal lines
* General segments (basically, all content types on the page).

## `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/barcode-reader/sample.pdf",
  "types": "QRCode,Code128,Code39,Interleaved2of5,EAN13",
  "pages": "0",
  "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}
{
  "barcodes": [
    {
      "Value": "box",
      "RawData": "",
      "Type": 53,
      "Rect": "{X=298,Y=437,Width=132,Height=6}",
      "Page": 0,
      "File": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-html/sample.pdf",
      "Confidence": 1,
      "Metadata": "",
      "TypeName": "UnderlinedField"
    }
  ],
  "pageCount": 1,
  "error": false,
  "status": 200,
  "duration": 860,
  "remainingCredits": 98725528,
  "credits": 35
}
```

#### `Example` CURL

```bash theme={null}
curl --location --request POST 'https://api.pdf.co/v1/barcode/read/from/url' \
--header 'x-api-key: *******************' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-html/sample.pdf",
"types": "Checkbox,UnderlinedField",
"async": false
}'
```

<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");

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


    // Direct URL of source file to search barcodes in.
    const SourceFileUrl = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/barcode-reader/sample.pdf";
    // Comma-separated list of barcode types to search.
    // See valid barcode types in the documentation https://developer.pdf.co
    const BarcodeTypes = "Code128,Code39,Interleaved2of5,EAN13";
    // Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'.
    const Pages = "";

    // Prepare request to `Barcode Reader` API endpoint
    var queryPath = `/v1/barcode/read/from/url`;

    // JSON payload for api request
    var jsonPayload = JSON.stringify({
        types: BarcodeTypes,
        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) {
                // Display found barcodes in console
                data.barcodes.forEach((element) => {
                    console.log("Found barcode:");
                    console.log("  Type: " + element.TypeName);
                    console.log("  Value: " + element.Value);
                    console.log("  Document Page Index: " + element.Page);
                    console.log("  Rectangle: " + element.Rect);
                    console.log("  Confidence: " + element.Confidence);
                    console.log("");
                }, this);
            }
            else {
                // Service reported error
                console.log(data.message);
            }
        });
    }).on("error", (e) => {
        // Request error
        console.error(e);
    });

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

  <Tab title="Python">
    ```python theme={null}
    import os
    import requests  # pip install requests

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

    # Base URL for PDF.co Web API requests
    BASE_URL = "https://api.pdf.co/v1"

    # Direct URL of source file to search barcodes in.
    SourceFileURL = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/barcode-reader/sample.pdf"

    # Comma-separated list of barcode types to search.
    # See valid barcode types in the documentation https://developer.pdf.co
    BarcodeTypes = "Code128,Code39,Interleaved2of5,EAN13"

    # Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'.
    Pages = ""


    def main(args=None):
        readBarcodes(SourceFileURL)

    def readBarcodes(uploadedFileUrl):
        """Get Barcode Information using PDF.co Web API"""

        # Prepare requests params as JSON
        # See documentation: https://developer.pdf.co
        parameters = {}
        parameters["types"] = BarcodeTypes
        parameters["pages"] = Pages
        parameters["url"] = uploadedFileUrl

        # Prepare URL for 'Barcode Reader' API request
        url = "{}/barcode/read/from/url".format(BASE_URL)

        # Execute request and get response as JSON
        response = requests.post(url, data=parameters, headers={ "x-api-key": API_KEY })
        if (response.status_code == 200):
            json = response.json()

            if json["error"] == False:
                # Display information
                for barcode in json["barcodes"]:
                    print("Found barcode:")
                    print(f"  Type: {barcode['TypeName']}")
                    print(f"  Value: {barcode['Value']}")
                    print(f"  Document Page Index: {barcode['Page']}")
                    print(f"  Rectangle: {barcode['Rect']}")
                    print(f"  Confidence: {barcode['Confidence']}")
                    print("")
            else:
                # Show service reported error
                print(json["message"])
        else:
            print(f"Request error: {response.status_code} {response.reason}")


    if __name__ == '__main__':
        main()
    ```
  </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 file (image or PDF) to search barcodes in.
            const string SourceFileURL = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/barcode-reader/sample.pdf";

            // Comma-separated list of barcode types to search.
            // See valid barcode types in the documentation https://developer.pdf.co
            const string BarcodeTypes = "Code128,Code39,Interleaved2of5,EAN13";

            // Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'.
            const string Pages = "";


            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);

                // Prepare requests params as JSON
                // See documentation: https://developer.pdf.co
                Dictionary<string, string> parameters = new Dictionary<string, string>();
                parameters.Add("url", SourceFileURL);
                parameters.Add("type", BarcodeTypes);
                parameters.Add("pages", Pages);
                // Convert dictionary of params to JSON
                string jsonPayload = JsonConvert.SerializeObject(parameters);

                try
                {
                    // URL of "Barcode Reader" endpoint
                    string url = "https://api.pdf.co/v1/barcode/read/from/url";

                    // 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)
                    {
                        // Display found barcodes in console
                        foreach (JToken token in json["barcodes"])
                        {
                            Console.WriteLine("Found barcode:");
                            Console.WriteLine("  Type: " + token["TypeName"]);
                            Console.WriteLine("  Value: " + token["Value"]);
                            Console.WriteLine("  Document Page Index: " + token["Page"]);
                            Console.WriteLine("  Rectangle: " + token["Rect"]);
                            Console.WriteLine("  Confidence: " + token["Confidence"]);
                            Console.WriteLine();
                        }
                    }
                    else
                    {
                        // Display service reported error
                        Console.WriteLine(json["message"].ToString());
                    }
                }
                catch (WebException e)
                {
                    // Display request error
                    Console.WriteLine(e.ToString());
                }
                finally
                {
                    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.JsonElement;
    import com.google.gson.JsonObject;
    import com.google.gson.JsonParser;
    import okhttp3.*;

    import java.io.*;
    import java.net.*;

    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 file to search barcodes in.
      final static String SourceFileURL = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/barcode-reader/sample.pdf";
        // Comma-separated list of barcode types to search.
        // See valid barcode types in the documentation https://developer.pdf.co
        final static String BarcodeTypes = "Code128,Code39,Interleaved2of5,EAN13";
        // Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'.
        final static String Pages = "";


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

            // Prepare URL for `Barcode Reader` API call
            String query = "https://api.pdf.co/v1/barcode/read/from/url";

            // 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("{\"types\": \"%s\", \"pages\": \"%s\", \"url\": \"%s\"}",
                BarcodeTypes,
                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)
                {
                    // Display found barcodes in console
                    for (JsonElement element : json.get("barcodes").getAsJsonArray())
                    {
                        JsonObject barcode = (JsonObject) element;
                        System.out.println("Found barcode:");
                        System.out.println("  Type: " + barcode.get("TypeName").getAsString());
                        System.out.println("  Value: " + barcode.get("Value").getAsString());
                        System.out.println("  Document Page Index: " + barcode.get("Page").getAsString());
                        System.out.println("  Rectangle: " + barcode.get("Rect").getAsString());
                        System.out.println("  Confidence: " + barcode.get("Confidence").getAsString());
                        System.out.println();
                    }
                }
                else
                {
                    // Display service reported error
                    System.out.println(json.get("message").getAsString());
                }
            }
            else
            {
                // Display request error
                System.out.println(response.code() + " " + response.message());
            }
        }
    }
    ```
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Cloud API asynchronous "Barcode Reader" job example (allows to avoid timeout errors).</title>
    </head>
    <body>

    <?php

    // Cloud API asynchronous "Barcode Reader" job example.
    // Allows to avoid timeout errors when processing huge or scanned PDF documents.


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

    // Direct URL of source file (image or PDF) to search barcodes in. Check another example if you need to upload a local file to the cloud.
    // 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/
    $sourceFileUrl = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/barcode-reader/sample.pdf";
    // Comma-separated list of barcode types to search.
    // See valid barcode types in the documentation https://developer.pdf.co
    $barcodeTypes = "Code128,Code39,Interleaved2of5,EAN13";
    // Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'.
    $pages = "";


    // Prepare URL for `Barcode Reader` API call
    $url = "https://api.pdf.co/v1/barcode/read/from/url";

    // Prepare requests params
    $parameters = array();
    $parameters["types"] = $barcodeTypes;
    $parameters["pages"] = $pages;
    $parameters["url"] = $sourceFileUrl;
    $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);
    echo $result . "<br/>";

    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 JSON 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 JSON file with information about decoded barcodes
                        echo "<div>## Conversion Result:<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;
    }

    ?>
    ```
  </Tab>
</Tabs>
