🧾 Generating Barcodes in Oracle APEX Using APEX_BARCODE

🧾 Generating Barcodes in Oracle APEX Using APEX_BARCODE

1. Introduction

This article explains How to Generating Barcodes in Oracle APEX Using APEX_BARCODE. The solution is implemented using a combination of Oracle APEX, PL/SQL and CSS.

2. Tools and Technologies

To achieve the desired functionality, the following technologies are used:

  • Oracle APEX
  • PL/SQL
  • CSS

3. Business Requirement

Many business applications require barcode generation to support daily operational needs such as inventory management, asset tracking, invoicing, shipping, and document identification. Traditionally, implementing barcode functionality in Oracle APEX applications involved using third-party libraries, external services, or custom integrations, which increased development complexity, cost, and security risks.

The business requires a simple, secure, and cost-effective solution to generate barcodes directly within Oracle APEX without relying on external tools or plugins. The solution must:

β€’ Generate barcodes dynamically based on application data (e.g., Order ID, Invoice Number, Asset Code).

β€’ Integrate seamlessly with existing Oracle APEX pages, reports, and forms.

β€’ Ensure consistent barcode rendering across environments (development, test, and production).

β€’ Reduce maintenance overhead and eliminate external dependencies.

β€’ Comply with enterprise security standards by keeping all processing inside the Oracle database and APEX framework.

Using the native APEX_BARCODE package fulfills this requirement by allowing businesses to generate high-quality barcodes efficiently while maintaining performance, security, and scalability.

This document outlines the steps required to Create a Floating Action Button (FAB) in Oracle APEX.

4. Implementation Steps

Step 1: Go to the Page Designer

Go to the Page designer where you want to Create Barcode. Create new Dynamic content Region. And Paste below code in PL/SQL.

DECLARE
    l_blob           BLOB;
    l_base64_data    CLOB;
    l_html_output    CLOB;
    
    l_target_url     VARCHAR2(200) := 'https://www.linkedin.com/groups/16258066/'; 
    
    l_title          VARCHAR2(100) := 'Oracle APEX Hub';
BEGIN
    l_blob := apex_barcode.get_code128_png(
                  p_value            => l_target_url, 
                  p_scale            => 2, 
                  p_foreground_color => '#333333',
                  p_background_color => '#ffffff' 
              );

    l_base64_data := apex_web_service.blob2clobbase64(l_blob);

    l_html_output := '<div class="barcode-card">' ||
                     '  <h3 class="barcode-title">' || l_title || '</h3>' ||
                     '  <img src="data:image/png;base64,' || l_base64_data || '" class="barcode-img" alt="Barcode" />' ||
                     '  <div class="barcode-caption">Scan to Visit</div>' ||
                     '</div>';

    RETURN l_html_output;
END;

Step 2: Now go to the page inline CSS

On same page, go to page inline css and paste below code.

.barcode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Soft shadow for depth */
    padding: 24px;
    max-width: 400px; /* Prevents it from being too wide */
    margin: 20px auto; /* Centers the card horizontally */
    transition: transform 0.2s ease;
}

/* Hover effect for interactivity */
.barcode-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* The actual image styling */
.barcode-img {
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 12px;
}

/* Optional caption text */
.barcode-caption {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

Step 3: Save and Run the page

5. Output

Following the above steps, you can Generate Barcodes in Oracle APEX Using APEX_BARCODE. This ensures a smoother and more user-friendly experience.

Thanks for reading! We hope this guide helped you to Generating Barcodes in Oracle APEX Using APEX_BARCODE.

Love coding? Me too! Let’s keep in touch – subscribe to my website for regular chats on Oracle APEX, PL/SQL,SQL JavaScript, and CSS.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    Your email address will not be published. Required fields are marked *