> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/smart-data-extraction/barcode.md).

# Server/Desktop Barcode Extraction

Discover how Apryse's Barcode Module can detect, read, and decode various barcode types in images and documents. Learn about the supported barcode formats and start your free trial to extract barcodes

## Overview

The Apryse Barcode Module enables fast, reliable detection and decoding of barcodes from documents and images. It supports **100+ barcode types**, including industry standards across logistics, healthcare, retail, and postal services.

Commonly supported types include:

* **QR**, **DataMatrix**, **PDF417**
* **EAN-8**, **EAN-13**, **Code 128**
* **Interleaved 2 of 5**, **PostNet**, **Planet**
* **USPS 4-State**, **Royal Mail 4-State**
* **PharmaCode**, **GS1-128**, and many more

## Installation Instructions

### Windows

Copy [BarcodeModuleWindows.zip](https://docs.apryse.com/downloads/BarcodeModuleWindows.zip) into your PDFNetC directory, then extract it locally. You should have files like

* Barcode\_README.md
* Lib\Windows\Barcode\BarcodeModule.dll
* Lib\Windows\Barcode\\\*.dll

### Linux

Copy [BarcodeModuleLinux.tar.gz](https://docs.apryse.com/downloads/BarcodeModuleLinux.tar.gz) into your PDFNetC directory, then extract it. You should have files like

* Barcode\_README.md
* Lib/Linux/BarcodeModule.so
* Lib/Linux/lib\*.so

## Usage

The first thing to set up before the module can be used is the location of the `Lib`directory where the external add-ons are installed, so the SDK knows where to look for them. This is achieved via the PDFNet `AddResourceSearchPath` function. If a relative path is used, it is based on the end-user executable.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
PDFNet.AddResourceSearchPath("../../../../../Lib/");
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
PDFNet::AddResourceSearchPath("../../../Lib/");
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
PDFNetAddResourceSearchPath("../../../PDFNetC/Lib/")
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFNet.addResourceSearchPath("../../../Lib/");
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
await PDFNet.addResourceSearchPath('../../lib/');
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
PDFNet::AddResourceSearchPath("../../../PDFNetC/Lib/");
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
PDFNet.AddResourceSearchPath("../../../PDFNetC/Lib/")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
PDFNet.AddResourceSearchPath("../../../PDFNetC/Lib/")
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
PDFNet.AddResourceSearchPath("../../../../../Lib/")
```

{% endcode %}
{% endtab %}
{% endtabs %}

Don't specify the actual Windows/Barcode or Linux/Barcode directories where the extension libraries are located; instead, specify the parent `Lib` folder. This allows you to add a single resource search path for all installed modules.

{% hint style="warning" %}
**Warning**

All files in the `Lib` folder of the archive must be present for the module to work as expected.
{% endhint %}

For error handling, it's generally advisable to first check whether the module is available using the `IsModuleAvailable` function.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
if (!BarcodeModule.IsModuleAvailable())
{
   // Barcode Module unavailable
}
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
if (!BarcodeModule::IsModuleAvailable())
{
   // Barcode Module unavailable
}
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
if !BarcodeModuleIsModuleAvailable() {
   // Barcode Module unavailable
}
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
if (!BarcodeModule.isModuleAvailable())
{
   // Barcode Module unavailable
}
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
if (!await PDFNet.BarcodeModule.isModuleAvailable()) {
   // Barcode Module unavailable
}
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
if (!BarcodeModule::IsModuleAvailable()) {
   // Barcode Module unavailable
}
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
if not BarcodeModule.IsModuleAvailable():
   pass # Barcode Module unavailable
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
if !BarcodeModule.IsModuleAvailable() then
   # Barcode Module unavailable
end
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
If Not BarcodeModule.IsModuleAvailable() Then
   ' Barcode Module unavailable
End If
```

{% endcode %}
{% endtab %}
{% endtabs %}

If you have the module installed but the function still returns false, please double check that the correct path was used in `AddResourceSearchPath` earlier.

## Barcode Extraction

The Barcode Module can detect and extract the barcodes present in a document, returning the result as JSON.

### Extract barcodes to JSON file

Specify the name of the input PDF file and the name of the output JSON file:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json");
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
BarcodeModule::ExtractBarcodes("barcodes.pdf", "barcodes.json");
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
BarcodeModuleExtractBarcodes("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
BarcodeModule.extractBarcodes("barcodes.pdf", "barcodes.json");
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
await PDFNet.BarcodeModule.extractBarcodes('barcodes.pdf', 'barcodes.json');
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
BarcodeModule::ExtractBarcodes("barcodes.pdf", "barcodes.json");
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Extract barcode data as JSON string

Specify the name of the input PDF file:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
string json = BarcodeModule.ExtractBarcodesAsString("barcodes.pdf", "barcodes.json");
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
UString json = BarcodeModule::ExtractBarcodesAsString("barcodes.pdf", "barcodes.json");
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
json := BarcodeModuleExtractBarcodesAsString("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
String json = BarcodeModule.extractBarcodesAsString("barcodes.pdf", "barcodes.json");
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const json = await PDFNet.BarcodeModule.extractBarcodesAsString('barcodes.pdf', 'barcodes.json');
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$json = BarcodeModule::ExtractBarcodesAsString("barcodes.pdf", "barcodes.json");
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
json = BarcodeModule.ExtractBarcodesAsString("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
json = BarcodeModule.ExtractBarcodesAsString("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim json As String = BarcodeModule.ExtractBarcodesAsString("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Barcode Options

Although the default options will satisfy most common use cases, we offer a couple of options to customize the extraction behavior and unlock lesser-used functionality.

The options object is passed as the last parameter to any extraction function, as shown below.

### Extraction Profile

As is the case with many detection problems, barcode extraction has an inherent tradeoff between accuracy and speed. We have exposed several "Barcode Profiles" which allow you to tailor this tradeoff to suit your specific needs. Currently, there are 4 profiles available:

* **High Quality Source Profile (default)**: This profile assumes a moderately high input quality, such as vector graphics, or an average to high quality scan of a flat paper. This setting provides the fastest barcode read performance.
* **Low Quality Source Profile**: This profile is useful for scanned paper of very poor quality, such as a low resolution or noisy scan. The barcode read performance is slightly slower.
* **Small Barcodes Profile**: This profile is suitable for vector graphics or scanned paper containing unusually small barcode(s). The barcode read performance is significantly slower.
* **Natural Picture Profile**: This profile should be selected for natural pictures, such as photographs of real-world objects that contain a barcode. Specifically, barcodes that are skewed relative to the image plane will be detected much more consistently when this profile is selected. The barcode read performance is significantly slower.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
BarcodeOptions options = new BarcodeOptions();
options.SetBarcodeProfile(BarcodeOptions.BarcodeProfile.e_small_barcodes_profile);
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
BarcodeOptions options;
options.SetBarcodeProfile(BarcodeOptions::e_small_barcodes_profile);
BarcodeModule::ExtractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
options := NewBarcodeOptions()
options.SetBarcodeProfile(BarcodeModuleE_SmallBarcodesProfile)
BarcodeModuleExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
BarcodeOptions options = new BarcodeOptions();
options.setBarcodeProfile(BarcodeOptions.BarcodeProfile.e_small_barcodes_profile);
BarcodeModule.extractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const options = new PDFNet.BarcodeModule.BarcodeOptions();
options.SetBarcodeProfile(PDFNet.BarcodeOptions.BarcodeProfile.e_small_barcodes_profile)
await PDFNet.BarcodeModule.extractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$options = new BarcodeOptions();
$options.SetBarcodeProfile(BarcodeOptions.BarcodeProfile.e_small_barcodes_profile)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", $options);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
options = BarcodeOptions()
options.SetBarcodeProfile(BarcodeOptions.BarcodeProfile.e_SmallBarcodesProfile)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
options = BarcodeOptions.new()
options.SetBarcodeProfile(BarcodeOptions::E_SmallBarcodesProfile)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim options As BarcodeOptions = New BarcodeOptions()
options.SetBarcodeProfile(BarcodeOptions.BarcodeProfile.e_small_barcodes_profile)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Select a Subset of Barcode Types

By default, all supported barcode types are searched for. If you are only interested in a subset of the supported barcode types, you can improve processing time by only searching for the types of interest. This is set using the `BarcodeTypeGroup`, which is a bitfield that can be bitwise OR'ed to combine multiple types. For example, if you were interested in QR and Micro QR codes, then you could specify `e_qr | e_micro_qr`.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
BarcodeOptions options = new BarcodeOptions();
options.SetBarcodeSearchTypes(BarcodeOptions.BarcodeSearchTypes.e_qr | BarcodeOptions.BarcodeSearchTypes.e_micro_qr);
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
BarcodeOptions options;
options.SetBarcodeSearchTypes(BarcodeOptions::e_qr | BarcodeOptions::e_micro_qr);
BarcodeModule::ExtractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
options := NewBarcodeOptions()
options.SetBarcodeSearchTypes(BarcodeModuleE_Qr | BarcodeModuleE_MicroQr)
BarcodeModuleExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
BarcodeOptions options = new BarcodeOptions();
options.setBarcodeSearchTypes(BarcodeOptions.BarcodeSearchTypes.e_qr | BarcodeOptions.BarcodeSearchTypes.e_micro_qr);
BarcodeModule.extractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const options = new PDFNet.BarcodeModule.BarcodeOptions();
options.SetBarcodeSearchTypes(PDFNet.BarcodeOptions.BarcodeSearchTypes.e_qr | PDFNet.BarcodeOptions.BarcodeSearchTypes.e_micro_qr)
await PDFNet.BarcodeModule.extractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$options = new BarcodeOptions();
$options.SetBarcodeSearchTypes(BarcodeOptions.BarcodeSearchTypes.e_qr | BarcodeOptions.BarcodeSearchTypes.e_micro_qr)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", $options);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
options = BarcodeOptions()
options.SetBarcodeSearchTypes(BarcodeOptions.BarcodeSearchTypes.e_Qr | BarcodeOptions.BarcodeSearchTypes.e_MicroQr)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
options = BarcodeOptions.new()
options.SetBarcodeSearchTypes(BarcodeOptions::E_Qr | BarcodeOptions::E_MicroQr)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim options As BarcodeOptions = New BarcodeOptions()
options.SetBarcodeSearchTypes(BarcodeOptions.BarcodeSearchTypes.e_qr | BarcodeOptions.BarcodeSearchTypes.e_micro_qr)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Search for Barcodes in a Particular Orientation

By default, all barcode orientations are searched for. If you have some prior knowledge of the orientation of the barcodes in your document, you can improve processing time by limiting the search to particular orientations. This is set using the `BarcodeOrientation`, which is a bitfield that can be bitwise OR'ed to combine multiple orientations. Supported orientations include:

* Horizontal
* Vertical
* Diagonal

For example, if you are only interested in barcodes that are oriented horizontally or vertically, you could specify `e_horizontal | e_vertical`.

{% hint style="info" %}
**NOTE**

This option only has an effect on the following barcode type groups (see [Barcode Types ](/core/smart-data-extraction/barcode/workflow.md#select-a-subset-of-barcode-types)):

* Linear
* Post Net Planet
* Four State
* GS1 Databar Stacked
* PDF417
* Micro PDF417
* Patch Code
* Pharma Code
  {% endhint %}

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
BarcodeOptions options = new BarcodeOptions();
options.SetBarcodeOrientations(BarcodeOptions.BarcodeOrientation.e_horizontal | BarcodeOptions.BarcodeOrientation.e_vertical);
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
BarcodeOptions options;
options.SetBarcodeOrientations(BarcodeOptions::e_horizontal | BarcodeOptions::e_vertical);
BarcodeModule::ExtractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
options := NewBarcodeOptions()
options.SetBarcodeOrientations(BarcodeModuleE_Horizontal | BarcodeModuleE_Vertical)
BarcodeModuleExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
BarcodeOptions options = new BarcodeOptions();
options.setBarcodeOrientations(BarcodeOptions.BarcodeOrientation.e_horizontal | BarcodeOptions.BarcodeOrientation.e_vertical);
BarcodeModule.extractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const options = new PDFNet.BarcodeModule.BarcodeOptions();
options.SetBarcodeOrientations(PDFNet.BarcodeOptions.BarcodeOrientation.e_horizontal | PDFNet.BarcodeOptions.BarcodeOrientation.e_vertical)
await PDFNet.BarcodeModule.extractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$options = new BarcodeOptions();
$options.SetBarcodeOrientations(BarcodeOptions.BarcodeOrientation.e_horizontal | BarcodeOptions.BarcodeOrientation.e_vertical)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", $options);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
options = BarcodeOptions()
options.SetBarcodeOrientations(BarcodeOptions.BarcodeOrientation.e_Horizontal | BarcodeOptions.BarcodeOrientation.e_Vertical)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
options = BarcodeOptions.new()
options.SetBarcodeOrientations(BarcodeOptions::E_Horizontal | BarcodeOptions::E_Vertical)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim options As BarcodeOptions = New BarcodeOptions()
options.SetBarcodeOrientations(BarcodeOptions.BarcodeOrientation.e_horizontal | BarcodeOptions.BarcodeOrientation.e_vertical)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Specify the Data Output Format

By default, barcodes will be decoded if possible. If the decoding is successful, the data will be stored in the `"text"` field of the output JSON. If the barcode data cannot be decoded, the data will be stored as a Base64-encoded string in the `"data"` field of the output JSON. If you would prefer to receive the data back in a consistent manner, or would prefer to decode the data yourself, you can force the module to return the encoded binary data (again, in the `"data"` field of the output JSON) by specifying `e_binary` as the output format

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
BarcodeOptions options = new BarcodeOptions();
options.SetDataOutputFormat(BarcodeOptions.OutputFormat.e_binary);
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
BarcodeOptions options;
options.SetDataOutputFormat(BarcodeOptions::e_binary);
BarcodeModule::ExtractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
options := NewBarcodeOptions()
options.SetDataOutputFormat(BarcodeModuleE_Binary)
BarcodeModuleExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
BarcodeOptions options = new BarcodeOptions();
options.setDataOutputFormat(BarcodeOptions.OutputFormat.e_binary);
BarcodeModule.extractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const options = new PDFNet.BarcodeModule.BarcodeOptions();
options.SetDataOutputFormat(PDFNet.BarcodeOptions.OutputFormat.e_binary)
await PDFNet.BarcodeModule.extractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$options = new BarcodeOptions();
$options.SetDataOutputFormat(BarcodeOptions.OutputFormat.e_binary)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", $options);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
options = BarcodeOptions()
options.SetDataOutputFormat(BarcodeOptions.OutputFormat.e_Binary)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json")
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
options = BarcodeOptions.new()
options.SetDataOutputFormat(BarcodeOptions::E_Binary)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim options As BarcodeOptions = New BarcodeOptions()
options.SetDataOutputFormat(BarcodeOptions.OutputFormat.e_binary)
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Select a Page Range

Use the `Pages` option to restrict the extraction to a selected range of pages.

This can be a single page number (such as `"1"` for the first page), or a range separated by a dash (such as `"1-5"`, or `"7-"` for 7 and beyond). An empty string (default) means all pages are extracted. Multiple ranges can be combined with commas, for example, `"1-3,5,10-"`.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
BarcodeOptions options = new BarcodeOptions();
options.SetPages("1"); // extract page 1
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
BarcodeOptions options;
options.SetPages("1"); // extract page 1
BarcodeModule::ExtractBarcodes("barcodes.pdf", "barcodes.json", BarcodeModule::e_Tabular, &options);
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code lineNumbers="true" %}

```go
options := NewBarcodeOptions()
options.SetPages("1") // page 1
BarcodeModuleExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
BarcodeOptions options = new BarcodeOptions();
options.setPages("1"); // extract page 1
BarcodeModule.extractBarcodes("barcodes.pdf", "barcodes.json", options);
```

{% endcode %}
{% endtab %}

{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const options = new PDFNet.BarcodeModule.BarcodeOptions();
options.setPages("1"); // page 1
await PDFNet.BarcodeModule.extractBarcodes('barcodes.pdf', 'barcodes.json', options);
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code lineNumbers="true" %}

```php
$options = new BarcodeOptions();
$options.setPages("1"); // page 1
BarcodeModule::ExtractBarcodes("barcodes.pdf", "barcodes.json", $options);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
options = BarcodeOptions()
options.SetPages("1") # page 1
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code lineNumbers="true" %}

```ruby
options = BarcodeOptions.new()
options.SetPages("1") # page 1
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}

{% tab title="VB" %}
{% code lineNumbers="true" %}

```vb
Dim options As BarcodeOptions = New BarcodeOptions()
options.SetPages("1") ' extract page 1
BarcodeModule.ExtractBarcodes("barcodes.pdf", "barcodes.json", options)
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Get started

[Set Up Apryse SDK Free Trial](/core/get-started/get-started.md) New to Apryse? This guide will walk you through the steps to create your license key and begin creating your application.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/smart-data-extraction/barcode.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
