Pdf - PdfBidimensionalBarcode
18 Nov 20262 minutes to read
Represents the common properties and drawing behavior for all supported 2D barcodes.
// 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
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.
Methods
draw
Draws the barcode on a PDF page or graphics context within the
supplied bounds and returns the occupied bounds.
// 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. |
| bounds | Rectangle |
The drawing bounds for the barcode. |
Returns Rectangle