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.