IRONSOFTWAREHOME
Add Barcodes in HTML to PDF
import {PdfDocument, BarcodeType} from "@ironsoftware/ironpdf";

(async () => {
    // Render HTML to PDF
    const pdf = await PdfDocument.fromHtml("<h1>Stamp Barcode</h1>");

    // Configure barcode options
    const barcodeOptions = {
        barcodeEncoding: BarcodeType.code39,
    };

    // Stamp barcode
    await pdf.stampBarcode("Hello World", barcodeOptions);

    // Export to a file
    await pdf.saveAs("bcTest.pdf");
})();
NuGet Download
Install-Package @ironsoftware/ironpdf
Add Barcodes in HTML to PDF

Add Barcodes in HTML to PDF

Barcodes can be applied directly to newly rendered PDFs or existing PDFs. Use the stampBarcode method to add a barcode to the PDF document. The only required input is the value that the barcode should represent.

However, in addition to this required input, there is also an optional barcode configuration object that can specify the following settings:

  • barcodeType: The encoding type of the barcode to use.
  • behindExistingContent: Set this to true to apply the stamp behind the content. If the content is opaque, the stamp may be invisible.
  • horizontalAlignment: The horizontal alignment of the stamp relative to the page.
  • horizontalOffset: The horizontal offset. A value of 0 has no effect. Positive values indicate an offset to the right, while negative values indicate an offset to the left.
  • verticalAlignment: The vertical alignment of the stamp relative to the page.
  • verticalOffset: The vertical offset. A value of 0 has no effect. Positive values indicate an offset downward, while negative values indicate an offset upward.
  • hyperlink: Allows stamped elements of this Stamper to have an on-click hyperlink.
  • maxHeight: The maximum height of the output stamp.
  • maxWidth: The maximum width of the output stamp.
  • minHeight: The minimum height of the output stamp.
  • minWidth: The minimum width of the output stamp.
  • opacity: Sets the opacity, allowing the stamp to be transparent. A value of 0 makes it fully invisible, while 100 makes it fully opaque.
  • renderDelay: Specifies the number of milliseconds to wait after HTML is rendered before printing. This can be useful when considering the rendering of JavaScript, Ajax, or animations.
  • rotation: Rotates the stamp clockwise from 0 to 360 degrees as specified.
  • scale: Applies a percentage scale to the stamps, making them larger or smaller.
  • timeout: Render timeout in seconds.
  • heightPx: The height in pixels of the barcode.
  • widthPx: The width in pixels of the barcode.

For more information about working with PDFs and barcodes, visit the IronPDF Documentation. Explore other libraries by Iron Software, such as IronBarcode for barcode generation, which can enhance your project capabilities.

Learn to Add Barcodes to PDFs with IronPDF for Node.js
View on GitHub

Ready to Get Started?

Version:2026.8just released

Key in blue circle

Get your free 30-day Trial Key instantly.

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required