2025 AI Readiness Report: Survey Insights on Enterprise AI Maturity – Now Available!
Apryse
Published June 24, 2025
Updated March 05, 2026
5 min
Apryse

Barcodes are a ubiquitous tool for handling data in many industries, and Apryse SDK provides the tools you need to work with them. In this sample code, check out how to read barcodes and convert to searchable PDF for use in other workflows.
Learn how the Apryse Server SDK now supports Alpine Linux for lightweight, secure server deployments
For more features and functionality of Apryse barcode recognition, check out the documentation, or contact us with any questions.
PRODUCTS
Platform Integrations
End User Applications
Popular Content
RESOURCES
#include <iostream>
#include <PDF/PDFNet.h>
#include <PDF/PDFDoc.h>
#include <PDF/OCRModule.h>
#include <PDF/OCROptions.h>
#include <PDF/BarcodeModule.h>
#include <PDF/BarcodeOptions.h>
#include <SDF/Obj.h>
using namespace pdftron;
using namespace std;
using namespace PDF;
using namespace SDF;
int main(int argc, char *argv[]) {
// Initialize the PDFNet library
PDFNet::Initialize("your_license_key");
// Add resource search paths for OCR and Barcode modules
PDFNet::AddResourceSearchPath("path_to_your_OCR_module");
PDFNet::AddResourceSearchPath("path_to_your_barcode_module");
try {
// Read barcodes from an input image
string input_path = "path_to_input.pdf";
string output_path = "path_to_output.json";
PDFDoc bcDoc(input_path);
BarcodeModule::ExtractBarcodes(bcDoc, output_path);
cout << "Barcodes extracted and saved to " << output_path << endl;
// Perform OCR on an input image and convert it to a searchable PDF
string ocr_input_image_path = "path_to_input.tif";
string searchable_pdf_path = "path_to_output.pdf";
PDFDoc doc;
OCROptions opts;
OCRModule::ImageToPDF(doc, ocr_input_image_path, &opts);
doc.Save(searchable_pdf_path, SDFDoc::e_linearized, 0);
cout << "Searchable PDF created and saved to " << searchable_pdf_path << endl;
} catch (const Common::Exception& e) {
cerr << "Error: " << e.what() << endl;
return 1;
}
return 0;
}