Pdf Component - Pdf417Barcode

18 Nov 20263 minutes to read

Represents a PDF417 two-dimensional barcode that can be drawn onto a PDF page or graphics context.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
// Add a page to the document
let page: PdfPage = document.addPage();
// Create a PDF417 barcode with the payload and drawing bounds
let barcode: Pdf417Barcode = new Pdf417Barcode('Hello World');
barcode.draw(page, { x: 10, y: 20, width: 200, height: 100 });
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();

Properties

barHeight number

Gets or sets the height of each bar (row).
Default is 0, which automatically calculates the height from xDimension.

text string

Gets or sets the barcode payload text. The default value is an empty string.

// Creates a document.
let document: PdfDocument = new PdfDocument();
// Creates a page.
let page: PdfPage = document.addPage();
// Creates a barcode.
let barcode: PdfCode39Barcode = new PdfCode39Barcode('ABC');
// Sets the text.
barcode.text = 'ABC-123';
// Draws the barcode at the specified point.
barcode.draw(page, { x: 20, y: 20 });
// Saves the document.
document.save('output.pdf');
// Destroys the document.
document.destroy();

Defaults to ’’

xDimension number

Gets or sets the width of one barcode module. The default value is 1.

Get errorCorrectionLevel Pdf417ErrorCorrectionLevel

Gets the error correction level of the barcode.

Set errorCorrectionLevel void

Sets the PDF417 error-correction level. The default value is auto.

Parameter Type Description
value Pdf417ErrorCorrectionLevel The error correction level value to set.

Methods

draw

Draws the barcode within the supplied bounds and returns the occupied bounds.
If the bounds are smaller than the required quiet zone, the barcode is automatically resized to fit.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
// Add a page to the document
let page: PdfPage = document.addPage();
// Create a PDF417 barcode with the payload and drawing bounds
let barcode: Pdf417Barcode = new Pdf417Barcode('Hello World');
barcode.draw(page, { x: 10, y: 20, width: 200, height: 100 });
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
Parameter Type Description
target PdfPage | PdfGraphics The PDF page or graphics context to draw on.
bounds Rectangle The drawing bounds for the barcode.

Returns Rectangle