useCommercialVersion(); $code->setScale(2); // Resolution $code->setThickness(30); // Thickness $code->setForegroundColor($colorBlack); // Color of bars $code->setBackgroundColor($colorWhite); // Color of spaces $code->setFont($font); // Font (or 0) $code->setChecksum(false); $code->parse($text); // Text $barcode = $code; } catch (Exception $exception) { $drawException = $exception; } $drawing = new BCGDrawing($barcode, $colorWhite); if ($drawException) { $drawing->drawException($drawException); } // Header that says it is an image (remove it if you save the barcode to a file) header('Content-Type: image/png'); header('Content-Disposition: inline; filename="barcode.png"'); // Draw (or save) the image into PNG format. $drawing->finish(BCGDrawing::IMG_FORMAT_PNG);