[Solved] How to add a barcode into invoice/quote template

ipl_barcode

First, upgrade MPDF library :

  • download current version at https://github.com/mpdf/mpdf

  • rename your current MDPF invoicePlane module vendor/mpdf to mpdf_BAK

  • upload new MDPF files into a vendor/mpd/mdpf folder

Edit your template file (here quote template application/views/quote_templates/pdf/InvoicePlane.php) by inserting a div tag (given sample is an alpha39 barcode with quote number) under <div id=“client”> :

	<?php echo '<div style="text-align:center;" class="barcodecell"><barcode code="'.$quote->quote_number.'" type="C39" class="barcode" />'; ?>
		<div style="text-align:center;"><?php echo trans('quote') . ' ' . $quote->quote_number; ?></div>
	</div>

You can do additional changes into assets/invoiceplane/css/templates.css to improve rendering styles.

Other barcode samples can be found at https://github.com/mpdf/mpdf-examples/blob/master/example37_barcodes.php

2 Likes

InvoicePlane.php (7.7 KB)

Full quote template with barcode and other changes

1 Like

@frg, I am implementing the barcode code and it does not allow me to generate the PDF

An uncaught Exception was encountered

Type: Mpdf\Barcode\BarcodeException

Message: Invalid CODE39 barcode value “Q200/#Q4

Filename: /vendor/mpdf/mpdf/src/Barcode/Code39.php

Line Number: 112

Backtrace:

File: /vendor/mpdf/mpdf/src/Barcode/Code39.php
Line: 19
Function: init

File: /vendor/mpdf/mpdf/src/Barcode.php
Line: 112
Function: __construct

File: /vendor/mpdf/mpdf/src/Barcode.php
Line: 10
Function: getBarcode

File: /vendor/mpdf/mpdf/src/Tag/BarCode.php
Line: 212
Function: getBarcodeArray

File: /vendor/mpdf/mpdf/src/Tag.php
Line: 240
Function: open

File: /vendor/mpdf/mpdf/src/Mpdf.php
Line: 13763
Function: OpenTag

File: /application/helpers/mpdf_helper.php
Line: 99
Function: WriteHTML

File: /application/helpers/pdf_helper.php
Line: 259
Function: pdf_create

File: /application/modules/guest/controllers/View.php
Line: 240
Function: generate_quote_pdf

File: /index.php
Line: 325
Function: require_once

Hi,

Character # is not supported by Code39, see https://en.wikipedia.org/wiki/Code_39

Try Code128 https://en.wikipedia.org/wiki/Code_128

2 Likes

Dear,

I need PDF417 code in Quotes.

Information which I need is:

  • My IBAN code
  • My business name
  • my Adress
  • My city
  • Number Quotes (example: 139-1-1, 140-1-1 etc.)
  • Total
1 Like

This topic was automatically closed after 35 hours. New replies are no longer allowed.