> 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/get-started/samples/pdfuatest.md).

# Convert to PDF/UA

Convert PDF to PDF/UA format using Apryse Server SDK. Sample code provided in Python, C++, C#, Java, Node.js (JavaScript), PHP, Ruby and VB.

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

*These packages are required to use these features in production. Trial keys have unlimited access to all features*

<a href="/core/get-started/get-started.md" class="button primary">Server SDK</a><a href="https://apryse.com/capabilities#Accessibility" class="button primary">Package: Accessibility</a><a href="/core/learn-more/modules.md#data-extraction-module" class="button primary">Module: Data Extraction</a><a href="https://showcase.apryse.com/pdfua-auto-tagging" class="button primary">Live demo</a>
{% endhint %}

Sample code for using Apryse SDK to programmatically convert generic PDF documents into ISO-compliant, VeraPDF-valid PDF/UA files. Supports PDF/UA-1. Sample code provided in Python, C++, C#, Java, Node.js (JavaScript), PHP, Ruby and VB.

### **Implementation steps**

To convert to PDF/UA with Apryse Server SDK:

Step 1: Follow [get started with Server SDK in your preferred language or framework](/core/get-started/get-started.md) Step 2: Download the [Data Extraction Module](/core/learn-more/modules.md#data-extraction-module) Step 3: Add the sample code provided in this guide

To use this feature in production, your license key will need the [Accessibility Package](https://apryse.com/capabilities#Accessibility). Trial keys already include all packages.

Learn more about our [Server SDK](/core/get-started/get-started.md) and [PDF/UA Library](/core/accessibility/pdfua.md).

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

```csharp
//
// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
//

using System;
using pdftron;
using pdftron.SDF;
using pdftron.PDF;
using pdftron.PDF.PDFUA;

//---------------------------------------------------------------------------------------
// The following sample illustrates how to make sure a file meets the PDF/UA standard, using the PDFUAConformance class object.
// Note: this feature is currently experimental and subject to change
//
// DataExtractionModule is required (Mac users can use StructuredOutputModule instead)
// https://docs.apryse.com/documentation/core/info/modules/#data-extraction-module
// https://docs.apryse.com/documentation/core/info/modules/#structured-output-module (Mac)
//---------------------------------------------------------------------------------------
namespace PDFUATestCS
{
	class PDFUATest
	{
		private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance();
		static PDFUATest() {}
		
		// Relative path to the folder containing test files.
		static string input_path =  "../../../../TestFiles/";
		static string output_path = "../../../../TestFiles/Output/";

		// DataExtraction library location, replace if desired, should point to a folder that includes the contents of <DataExtractionModuleRoot>/Lib.
		// If using default, unzip the DataExtraction zip to the parent folder of Samples, and merge with existing "Lib" folder
		static string extraction_module_path = "../../../../../Lib/";


		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main(string[] args)
		{
			try {
				PDFNet.Initialize(PDFTronLicense.Key);

				String input_file1 = input_path + "autotag_input.pdf";
				String input_file2 = input_path + "table.pdf";
				String output_file1 = output_path + "autotag_pdfua.pdf";
				String output_file2 = output_path + "table_pdfua_linearized.pdf";

				//-----------------------------------------------------------
				// Example: PDF/UA Conversion
				//-----------------------------------------------------------
				Console.WriteLine("AutoConverting...");

				PDFNet.AddResourceSearchPath(extraction_module_path);
				if(!DataExtractionModule.IsModuleAvailable(DataExtractionModule.DataExtractionEngine.e_doc_structure))
				{
					Console.Error.WriteLine("Unable to run PDFUATest: Apryse SDK Data Extraction module not available.");
					Console.Error.WriteLine("---------------------------------------------------------------");
					Console.Error.WriteLine("The Data Extraction module is an optional add-on, available for download");
					Console.Error.WriteLine("at https://apryse.com/. If you have already downloaded this");
					Console.Error.WriteLine("module, ensure that the SDK is able to find the required files");
					Console.Error.WriteLine("using the PDFNet::AddResourceSearchPath() function.");
					Console.Error.WriteLine("");
					return;
				}

				PDFUAConformance pdf_ua = new PDFUAConformance();

				Console.WriteLine("Simple Conversion...");
				{
					// Perform conversion using default options
					pdf_ua.AutoConvert(input_file1, output_file1);
				}

				Console.WriteLine("Converting With Options...");
				{
					PDFUAOptions pdf_ua_opts = new PDFUAOptions();
					pdf_ua_opts.SetSaveLinearized(true); // Linearize when saving output
					// Note: if file is password protected, you can use pdf_ua_opts.setPassword()

					// Perform conversion using the options we specify
					pdf_ua.AutoConvert(input_file2, output_file2, pdf_ua_opts);
				}

			}
			catch (pdftron.Common.PDFNetException e)
			{
				Console.Error.WriteLine(e.GetMessage());
				Environment.Exit(-1);
			}
			finally
			{
				PDFNet.Terminate();
				Console.WriteLine("PDFUAConformance test completed.");
			}
		}
	}
}
```

{% endcode %}
{% endtab %}

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

```go
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
// Consult LICENSE.txt regarding license information.
//---------------------------------------------------------------------------------------

package main
import (
	"fmt"
	"testing"
	"flag"
	. "github.com/pdftron/pdftron-go/v2"
)

var licenseKey string
var modulePath string

func init() {
	flag.StringVar(&licenseKey, "license", "", "License key for Apryse SDK")
	flag.StringVar(&modulePath, "modulePath", "", "Module path for Apryse SDK")
}

//---------------------------------------------------------------------------------------
// The following sample illustrates how to make sure a file meets the PDF/UA standard, using the PDFUAConformance class object.
// Note: this feature is currently experimental and subject to change
//
// DataExtractionModule is required (Mac users can use StructuredOutputModule instead)
// https://docs.apryse.com/documentation/core/info/modules/#data-extraction-module
// https://docs.apryse.com/documentation/core/info/modules/#structured-output-module (Mac)
//---------------------------------------------------------------------------------------

// Relative path to the folder containing the test files.
var inputPath = "../TestFiles/"
var outputPath = "../TestFiles/Output/"

func TestPDFUA(t *testing.T) {

	inputFile1 := inputPath + "autotag_input.pdf"
	inputFile2 := inputPath + "table.pdf"
	outputFile1 := outputPath + "autotag_pdfua.pdf"
	outputFile2 := outputPath + "table_pdfua_linearized.pdf"

	PDFNetInitialize(licenseKey)

	fmt.Println("AutoConverting...")

	PDFNetAddResourceSearchPath(modulePath)

	if !DataExtractionModuleIsModuleAvailable(DataExtractionModuleE_DocStructure) {
		fmt.Println("")
		fmt.Println("Unable to run Data Extraction: PDFTron SDK Structured Output module not available.")
		fmt.Println("-----------------------------------------------------------------------------")
		fmt.Println("The Data Extraction suite is an optional add-on, available for download")
		fmt.Println("at https://docs.apryse.com/documentation/core/info/modules/. If you have already")
		fmt.Println("downloaded this module, ensure that the SDK is able to find the required files")
		fmt.Println("using the PDFNetAddResourceSearchPath() function.")
		fmt.Println("")
		PDFNetTerminate()
		return
	}

	pdfua := NewPDFUAConformance()

	fmt.Println("Simple Conversion...")

	// Perform conversion using default options
	pdfua.AutoConvert(inputFile1, outputFile1)

	fmt.Println("Converting With Options...")

	pdfuaOpts := NewPDFUAOptions()
	pdfuaOpts.SetSaveLinearized(true) // Linearize when saving output
	// Note: if file is password protected, you can use pdfuaOpts.SetPassword()

	// Perform conversion using the options we specify
	pdfua.AutoConvert(inputFile2, outputFile2, pdfuaOpts)

	PDFNetTerminate()
	fmt.Println("PDFUAConformance test completed.")
}
```

{% endcode %}
{% endtab %}

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

```java
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------

import com.pdftron.common.PDFNetException;
import com.pdftron.pdf.*;
import com.pdftron.pdf.pdfua.*;

//---------------------------------------------------------------------------------------
// The following sample illustrates how to make sure a file meets the PDF/UA standard, using the PDFUAConformance class object.
// Note: this feature is currently experimental and subject to change
//
// DataExtractionModule is required (Mac users can use StructuredOutputModule instead)
// https://docs.apryse.com/documentation/core/info/modules/#data-extraction-module
// https://docs.apryse.com/documentation/core/info/modules/#structured-output-module (Mac)
//---------------------------------------------------------------------------------------
public class PDFUATest {

    // Relative path to the folder containing test files.
    public static final String input_path = "../../TestFiles/";
    public static final String output_path = "../../TestFiles/Output/";

    // DataExtraction library location, replace if desired, should point to a folder that includes the contents of <DataExtractionModuleRoot>/Lib.
    // If using default, unzip the DataExtraction zip to the parent folder of Samples, and merge with existing "Lib" folder
    public static final String extraction_module_path = "../../../Lib/";

    public static void main(String[] args) {
        try {
            PDFNet.initialize(PDFTronLicense.Key());

            String input_file1 = input_path + "autotag_input.pdf";
            String input_file2 = input_path + "table.pdf";
            String output_file1 = output_path + "autotag_pdfua.pdf";
            String output_file2 = output_path + "table_pdfua_linearized.pdf";

            //-----------------------------------------------------------
            // Example: PDF/UA Conversion
            //-----------------------------------------------------------
            System.out.println("AutoConverting...");

            PDFNet.addResourceSearchPath(extraction_module_path);
            if(!DataExtractionModule.isModuleAvailable(DataExtractionModule.DataExtractionEngine.e_doc_structure))
            {
                System.out.println("Unable to run PDFUATest: Apryse SDK Data Extraction module not available.");
                System.out.println("---------------------------------------------------------------");
                System.out.println("The Data Extraction module is an optional add-on, available for download");
                System.out.println("at https://apryse.com/. If you have already downloaded this");
                System.out.println("module, ensure that the SDK is able to find the required files");
                System.out.println("using the PDFNet::AddResourceSearchPath() function.");
                System.out.println("");
                return;
            }

            PDFUAConformance pdf_ua = new PDFUAConformance();

            System.out.println("Simple Conversion...");
            {
                // Perform conversion using default options
                pdf_ua.autoConvert(input_file1, output_file1);
            }

            System.out.println("Converting With Options...");
            {
                PDFUAOptions pdf_ua_opts = new PDFUAOptions();
                pdf_ua_opts.setSaveLinearized(true); // Linearize when saving output
                // Note: if file is password protected, you can use pdf_ua_opts.setPassword()

                // Perform conversion using the options we specify
                pdf_ua.autoConvert(input_file2, output_file2, pdf_ua_opts);
            }

        } catch (PDFNetException e) {
            System.out.println(e.getMessage());
        } finally {
            PDFNet.terminate();
            System.out.println("PDFUAConformance test completed.");
        }
    }

}
```

{% endcode %}
{% endtab %}

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

```cpp
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------
#include <iostream>
#include <PDF/PDFNet.h>
#include <PDF/DataExtractionModule.h>
#include "../../LicenseKey/CPP/LicenseKey.h"
#include <PDF/PDFUA/PDFUAConformance.h>
#include <PDF/PDFUA/PDFUAOptions.h>
using namespace std;
using namespace pdftron;
using namespace pdftron::PDF;
using namespace pdftron::PDF::PDFUA;
//---------------------------------------------------------------------------------------
// The following sample illustrates how to make sure a file meets the PDF/UA standard, using the PDFUAConformance class object.
// Note: this feature is currently experimental and subject to change
//
// DataExtractionModule is required (Mac users can use StructuredOutputModule instead)
// https://docs.apryse.com/documentation/core/info/modules/#data-extraction-module
// https://docs.apryse.com/documentation/core/info/modules/#structured-output-module (Mac)
//---------------------------------------------------------------------------------------
int main(int argc, char *argv[])
{
	// Relative path to the folder containing test files.
	static UString input_path("../../TestFiles/");
	static UString output_path("../../TestFiles/Output/");
	// DataExtraction library location, replace if desired, should point to a folder that includes the contents of <DataExtractionModuleRoot>/Lib.
	// If using default, unzip the DataExtraction zip to the parent folder of Samples, and merge with existing "Lib" folder.
	static UString extraction_module_path("../../../Lib/");
	UString input_file1 = input_path + "autotag_input.pdf";
	UString input_file2 = input_path + "table.pdf";
	UString output_file1 = output_path + "autotag_pdfua.pdf";
	UString output_file2 = output_path + "table_pdfua_linearized.pdf";
	int ret = 0;
	try
	{
		PDFNet::Initialize(LicenseKey);
		cout << "AutoConverting..." << endl;
		PDFNet::AddResourceSearchPath(extraction_module_path);
		if (!DataExtractionModule::IsModuleAvailable(DataExtractionModule::e_DocStructure))
		{
			cout << endl;
			cout << "Unable to run PDFUATest: Apryse SDK Data Extraction module not available." << endl;
			cout << "---------------------------------------------------------------" << endl;
			cout << "The Data Extraction module is an optional add-on, available for download" << endl;
			cout << "at https://apryse.com/. If you have already downloaded this" << endl;
			cout << "module, ensure that the SDK is able to find the required files" << endl;
			cout << "using the PDFNet::AddResourceSearchPath() function." << endl << endl;
			return 1;
		}
		PDFUAConformance pdf_ua;
		cout << "Simple Conversion..." << endl;
		{
			// Perform conversion using default options
			pdf_ua.AutoConvert(input_file1, output_file1);
		}
		cout << "Converting With Options..." << endl;
		{
			PDFUAOptions pdf_ua_opts;
			pdf_ua_opts.SetSaveLinearized(true); // Linearize when saving output
			// Note: if file is password protected, you can use pdf_ua_opts.SetPassword()
			// Perform conversion using the options we specify
			pdf_ua.AutoConvert(input_file2, output_file2, pdf_ua_opts);
		}
	}
	catch (Common::Exception& e)
	{
		cout << e << endl;
		ret = 1;
	}
	catch (...) {
		cout << "Unknown Exception" << endl;
		ret = 1;
	}
	cout << "PDFUAConformance test completed." << endl;
	PDFNet::Terminate();
	return ret;
}
```

{% endcode %}
{% endtab %}

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

```js
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------
const { PDFNet } = require('../../lib/pdfnet.js');
const PDFTronLicense = require('../../LicenseKey/NODEJS/LicenseKey');
((exports) => {
	'use strict';
	exports.runPDFUATest = () => {
		//---------------------------------------------------------------------------------------
		// The following sample illustrates how to make sure a file meets the PDF/UA standard, using the PDFUAConformance class object.
		// Note: this feature is currently experimental and subject to change
		//
		// DataExtractionModule is required (Mac users can use StructuredOutputModule instead)
		// https://docs.apryse.com/documentation/core/info/modules/#data-extraction-module
		// https://docs.apryse.com/documentation/core/info/modules/#structured-output-module (Mac)
		//---------------------------------------------------------------------------------------
		const main = async () => {
			// Relative path to the folder containing test files.
			const input_path = '../TestFiles/';
			const output_path = '../TestFiles/Output/';
			// DataExtraction library location, replace if desired, should point to a folder that includes the contents of <DataExtractionModuleRoot>/Lib.
			// If using default, unzip the DataExtraction zip to the parent folder of Samples, and merge with existing "Lib" folder
			const extraction_module_path = '../../lib/';
			const input_file1 = input_path + 'autotag_input.pdf';
			const input_file2 = input_path + 'table.pdf';
			const output_file1 = output_path + 'autotag_pdfua.pdf';
			const output_file2 = output_path + 'table_pdfua_linearized.pdf';
			try {
				//-----------------------------------------------------------
				// Example: PDF/UA Conversion
				//-----------------------------------------------------------
				console.log('AutoConverting...');
				await PDFNet.addResourceSearchPath(extraction_module_path);
				if (!await PDFNet.DataExtractionModule.isModuleAvailable(PDFNet.DataExtractionModule.DataExtractionEngine.e_DocStructure)) {
					console.log('');
					console.log('Unable to run PDFUATest: Apryse SDK Data Extraction module not available.');
					console.log('---------------------------------------------------------------');
					console.log('The Data Extraction module is an optional add-on, available for download');
					console.log('at https://apryse.com/. If you have already downloaded this');
					console.log('module, ensure that the SDK is able to find the required files');
					console.log('using the PDFNet.addResourceSearchPath() function.');
					console.log('');
					return;
				}
				const pdf_ua = await PDFNet.PDFUAConformance.create();
				console.log('Simple Conversion...');
				{
					// Perform conversion using default options
					await pdf_ua.autoConvert(input_file1, output_file1);
				}
				console.log('Converting With Options...');
				{
					const pdf_ua_opts = await PDFNet.PDFUAConformance.createPDFUAOptions();
					pdf_ua_opts.setSaveLinearized(true); // Linearize when saving output
					// Note: if file is password protected, you can use pdf_ua_opts.setPassword()
					// Perform conversion using the options we specify
					await pdf_ua.autoConvert(input_file2, output_file2, pdf_ua_opts);
				}
			} catch (err) {
				console.log(err);
			}
			console.log('PDFUAConformance test completed.');
		}
		PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
			console.log('Error: ' + JSON.stringify(error));
		}).then(function () { return PDFNet.shutdown(); });
	};
	exports.runPDFUATest();
})(exports);
// eslint-disable-next-line spaced-comment
//# sourceURL=PDFUATest.js
```

{% endcode %}
{% endtab %}

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

```php
<?php
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
// Consult LICENSE.txt regarding license information.
//---------------------------------------------------------------------------------------
if(file_exists("../../../PDFNetC/Lib/PDFNetPHP.php"))
include("../../../PDFNetC/Lib/PDFNetPHP.php");
include("../../LicenseKey/PHP/LicenseKey.php");
//---------------------------------------------------------------------------------------
// The following sample illustrates how to make sure a file meets the PDF/UA standard, using the PDFUAConformance class object.
// Note: this feature is currently experimental and subject to change
//
// DataExtractionModule is required (Mac users can use StructuredOutputModule instead)
// https://docs.apryse.com/documentation/core/info/modules/#data-extraction-module
// https://docs.apryse.com/documentation/core/info/modules/#structured-output-module (Mac)
//---------------------------------------------------------------------------------------
function main()
{
	// Relative path to the folder containing the test files.
	$input_path = "../../TestFiles/";
	$output_path = "../../TestFiles/Output/";
	// DataExtraction library location, replace if desired, should point to a folder that includes the contents of <DataExtractionModuleRoot>/Lib.
	// If using default, unzip the DataExtraction zip to the parent folder of Samples, and merge with existing "Lib" folder.
	$extraction_module_path = "../../../PDFNetC/Lib/";
	$input_file1 = $input_path."autotag_input.pdf";
	$input_file2 = $input_path."table.pdf";
	$output_file1 = $output_path."autotag_pdfua.pdf";
	$output_file2 = $output_path."table_pdfua_linearized.pdf";
	global $LicenseKey;
	PDFNet::Initialize($LicenseKey);
	PDFNet::GetSystemFontList();
	echo(nl2br("AutoConverting...\n"));
	PDFNet::AddResourceSearchPath($extraction_module_path);
	if (!DataExtractionModule::IsModuleAvailable(DataExtractionModule::e_DocStructure)) {
		echo(nl2br("\n"));
		echo(nl2br("Unable to run Data Extraction: PDFTron SDK Structured Output module not available.\n"));
		echo(nl2br("-----------------------------------------------------------------------------\n"));
		echo(nl2br("The Data Extraction suite is an optional add-on, available for download\n"));
		echo(nl2br("at https://docs.apryse.com/documentation/core/info/modules/. If you have already\n"));
		echo(nl2br("downloaded this module, ensure that the SDK is able to find the required files\n"));
		echo(nl2br("using the PDFNet::AddResourceSearchPath() function.\n"));
		echo(nl2br("\n"));
		PDFNet::Terminate();
		return;
	}
	try {
		$pdf_ua = new PDFUAConformance();
		echo(nl2br("Simple Conversion...\n"));
		// Perform conversion using default options
		$pdf_ua->AutoConvert($input_file1, $output_file1);
		echo(nl2br("Converting With Options...\n"));
		$pdf_ua_opts = new PDFUAOptions();
		$pdf_ua_opts->SetSaveLinearized(true); // Linearize when saving output
		// Note: if file is password protected, you can use $pdf_ua_opts->SetPassword()
		// Perform conversion using the options we specify
		$pdf_ua->AutoConvert($input_file2, $output_file2, $pdf_ua_opts);
	}
	catch(Exception $e) {
		echo(nl2br($e->getMessage()));
	}
	PDFNet::Terminate();
	echo(nl2br("PDFUAConformance test completed.\n"));
}
main();
?>
```

{% endcode %}
{% endtab %}

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

```python
#---------------------------------------------------------------------------------------
# Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
# Consult LICENSE.txt regarding license information.
#---------------------------------------------------------------------------------------
import site
site.addsitedir("../../../PDFNetC/Lib")
import sys
from PDFNetPython import *
sys.path.append("../../LicenseKey/PYTHON")
from LicenseKey import *
#---------------------------------------------------------------------------------------
# The following sample illustrates how to make sure a file meets the PDF/UA standard, using the PDFUAConformance class object.
# Note: this feature is currently experimental and subject to change
#
# DataExtractionModule is required (Mac users can use StructuredOutputModule instead)
# https://docs.apryse.com/documentation/core/info/modules/#data-extraction-module
# https://docs.apryse.com/documentation/core/info/modules/#structured-output-module (Mac)
#---------------------------------------------------------------------------------------
# Relative path to the folder containing the test files.
input_path = "../../TestFiles/"
output_path = "../../TestFiles/Output/"
# DataExtraction library location, replace if desired, should point to a folder that includes the contents of <DataExtractionModuleRoot>/Lib.
# If using default, unzip the DataExtraction zip to the parent folder of Samples, and merge with existing "Lib" folder.
extraction_module_path = "../../../PDFNetC/Lib/"
def main():
    input_file1 = input_path + "autotag_input.pdf"
    input_file2 = input_path + "table.pdf"
    output_file1 = output_path + "autotag_pdfua.pdf"
    output_file2 = output_path + "table_pdfua_linearized.pdf"
    PDFNet.Initialize(LicenseKey)
    print("AutoConverting...")
    PDFNet.AddResourceSearchPath(extraction_module_path)
    if not DataExtractionModule.IsModuleAvailable(DataExtractionModule.e_DocStructure):
        print("")
        print("Unable to run Data Extraction: PDFTron SDK Structured Output module not available.")
        print("-----------------------------------------------------------------------------")
        print("The Data Extraction suite is an optional add-on, available for download")
        print("at https://docs.apryse.com/documentation/core/info/modules/. If you have already")
        print("downloaded this module, ensure that the SDK is able to find the required files")
        print("using the PDFNet.AddResourceSearchPath() function.")
        print("")
        PDFNet.Terminate()
        return
    try:
        pdf_ua = PDFUAConformance()
        print("Simple Conversion...")
        # Perform conversion using default options
        pdf_ua.AutoConvert(input_file1, output_file1)
        print("Converting With Options...")
        pdf_ua_opts = PDFUAOptions()
        pdf_ua_opts.SetSaveLinearized(True)  # Linearize when saving output
        # Note: if file is password protected, you can use pdf_ua_opts.SetPassword()
        # Perform conversion using the options we specify
        pdf_ua.AutoConvert(input_file2, output_file2, pdf_ua_opts)
    except Exception as e:
        print(str(e))
    PDFNet.Terminate()
    print("PDFUAConformance test completed.")
if __name__ == '__main__':
    main()
```

{% endcode %}
{% endtab %}

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

```ruby
#---------------------------------------------------------------------------------------
# Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
# Consult LICENSE.txt regarding license information.
#---------------------------------------------------------------------------------------
require '../../../PDFNetC/Lib/PDFNetRuby'
include PDFNetRuby
require '../../LicenseKey/RUBY/LicenseKey'
$stdout.sync = true
#---------------------------------------------------------------------------------------
# The following sample illustrates how to make sure a file meets the PDF/UA standard, using the PDFUAConformance class object.
# Note: this feature is currently experimental and subject to change
#
# DataExtractionModule is required (Mac users can use StructuredOutputModule instead)
# https://docs.apryse.com/documentation/core/info/modules/#data-extraction-module
# https://docs.apryse.com/documentation/core/info/modules/#structured-output-module (Mac)
#---------------------------------------------------------------------------------------
# Relative path to the folder containing the test files.
$input_path = "../../TestFiles/"
$output_path = "../../TestFiles/Output/"
# DataExtraction library location, replace if desired, should point to a folder that includes the contents of <DataExtractionModuleRoot>/Lib.
# If using default, unzip the DataExtraction zip to the parent folder of Samples, and merge with existing "Lib" folder.
$extraction_module_path = "../../../PDFNetC/Lib/"
def main()
	input_file1 = $input_path + "autotag_input.pdf"
	input_file2 = $input_path + "table.pdf"
	output_file1 = $output_path + "autotag_pdfua.pdf"
	output_file2 = $output_path + "table_pdfua_linearized.pdf"
	PDFNet.Initialize(PDFTronLicense.Key)
	puts "AutoConverting..."
	PDFNet.AddResourceSearchPath($extraction_module_path)
	if !DataExtractionModule.IsModuleAvailable(DataExtractionModule::E_DocStructure) then
		puts ""
		puts "Unable to run Data Extraction: PDFTron SDK Structured Output module not available."
		puts "-----------------------------------------------------------------------------"
		puts "The Data Extraction suite is an optional add-on, available for download"
		puts "at https://docs.apryse.com/documentation/core/info/modules/. If you have already"
		puts "downloaded this module, ensure that the SDK is able to find the required files"
		puts "using the PDFNet.AddResourceSearchPath() function."
		puts ""
		PDFNet.Terminate
		return
	end
	begin
		pdf_ua = PDFUAConformance.new()
		puts "Simple Conversion..."
		# Perform conversion using default options
		pdf_ua.AutoConvert(input_file1, output_file1)
		puts "Converting With Options..."
		pdf_ua_opts = PDFUAOptions.new()
		pdf_ua_opts.SetSaveLinearized(true) # Linearize when saving output
		# Note: if file is password protected, you can use pdf_ua_opts.SetPassword()
		# Perform conversion using the options we specify
		pdf_ua.AutoConvert(input_file2, output_file2, pdf_ua_opts)
	rescue => error
		puts error.message
	end
	PDFNet.Terminate
	puts "PDFUAConformance test completed."
end
main()
```

{% endcode %}
{% endtab %}

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

```vb
'---------------------------------------------------------------------------------------
' Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
' Consult legal.txt regarding legal and license information.     
'---------------------------------------------------------------------------------------
Imports System

Imports pdftron
Imports pdftron.PDF
Imports PDFTRON.PDF.PDFUA

'//---------------------------------------------------------------------------------------
'// The following sample illustrates how to make sure a file meets the PDF/UA standard, using the PDFUAConformance class object.
'// Note: this feature is currently experimental and subject to change
'//
'// DataExtractionModule is required (Mac users can use StructuredOutputModule instead)
'// https://docs.apryse.com/documentation/core/info/modules/#data-extraction-module
'// https://docs.apryse.com/documentation/core/info/modules/#structured-output-module (Mac)
'//---------------------------------------------------------------------------------------

Module mainModule
    Dim pdfNetLoader As PDFNetLoader
    Sub New()
        pdfNetLoader = pdftron.PDFNetLoader.Instance()
    End Sub

    '// Relative path to the folder containing test files.
    Dim input_path As String =  "../../../../TestFiles/"
    Dim output_path As String = "../../../../TestFiles/Output/"

    '// DataExtraction library location, replace if desired, should point to a folder that includes the contents of <DataExtractionModuleRoot>/Lib.
    '// If using default, unzip the DataExtraction zip to the parent folder of Samples, and merge with existing "Lib" folder
    Dim extraction_module_path As String = "../../../../../Lib/"

    ' The main entry point for the application.
    Sub Main()

        PDFNet.Initialize(PDFTronLicense.Key)

        Try
            Dim input_file1 As String = input_path + "autotag_input.pdf"
            Dim input_file2 As String = input_path + "table.pdf"
            Dim output_file1 As String = output_path + "autotag_pdfua.pdf"
            Dim output_file2 As String = output_path + "table_pdfua_linearized.pdf"

            '//-----------------------------------------------------------
            '// Example: PDF/UA Conversion
            '//-----------------------------------------------------------
            Console.WriteLine("AutoConverting...")

            PDFNet.AddResourceSearchPath(extraction_module_path)
            If Not DataExtractionModule.IsModuleAvailable(DataExtractionModule.DataExtractionEngine.e_doc_structure) Then
                Console.WriteLine("Unable to run PDFUATest: Apryse SDK Data Extraction module not available.")
                Console.WriteLine("---------------------------------------------------------------")
                Console.WriteLine("The Data Extraction module is an optional add-on, available for download")
                Console.WriteLine("at https://apryse.com/. If you have already downloaded this")
                Console.WriteLine("module, ensure that the SDK is able to find the required files")
                Console.WriteLine("using the PDFNet::AddResourceSearchPath() function.")
                Console.WriteLine()
                Return
            End If

            Dim pdf_ua As PDFUAConformance = New PDFUAConformance()

            Console.WriteLine("Simple Conversion...")

            '// Perform conversion using default options
            pdf_ua.AutoConvert(input_file1, output_file1)


            Console.WriteLine("Converting With Options...")

            Dim pdf_ua_opts As PDFUAOptions = New PDFUAOptions()
            pdf_ua_opts.SetSaveLinearized(True) '// Linearize When saving output
            '// Note: if file is password protected, you can use pdf_ua_opts.setPassword()

            '// Perform conversion using the options we specify
            pdf_ua.AutoConvert(input_file2, output_file2, pdf_ua_opts)
        Catch e As PDFTRON.Common.PDFNetException
            Console.WriteLine(e.Message)
        End Try

        PDFNet.Terminate()
        Console.WriteLine("PDFUAConformance test completed.")
    End Sub

End Module
```

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


---

# 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/get-started/samples/pdfuatest.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.
