I have to get data from a table and print it on page and also have to print a barcode image based on a field value, following is the code, but the error is that it shows everything as image, but if I remove the header content-type then everything shown as text.
Please help me.
PHP Code:
<?php
// Including all required classes
require_once('class/BCGFontFile.php');
require_once('class/BCGColor.php');
require_once('class/BCGDrawing.php');
require_once("dbConnect.php");
// Including the barcode technology
require_once('class/BCGcode39.barcode.php');
// Loading Font
$font = new BCGFontFile('./class/font/Arial.ttf', 12);
//Data
$classID = $_POST['txtclassID'];
$RollNo = $_POST['D1'];
$cDate = $_POST['cDate'];
$RNumber = $_POST['RNumber'];
$Amount = $_POST['Amount'];
$forMonth = $_POST['FormonthOf'];
$AccountOf = $_POST['AccountOf'];
$Desc = $_POST['Desc'];
$cCode=$_POST['cCode'];
//Data
$sql=mysql_query("select * from class where classID='$classID'");
$row = mysql_fetch_assoc($sql);
$class = $row['class'];
$section=$row['section'];
$session=$row['session'];
$sql2= mysql_query("select studName from biodata where rollnum='$RollNo'");
$row2=mysql_fetch_assoc($sql2);
$name = $row2['studName'];
// The arguments are R, G, B for color.
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
$drawException = null;
try {
$code = new BCGcode39();
$code->setScale(2); // Resolution
$code->setThickness(30); // Thickness
$code->setForegroundColor($color_black); // Color of bars
$code->setBackgroundColor($color_white); // Color of spaces
$code->setFont($font); // Font (or 0)
$code->parse($cCode); // Text
} catch(Exception $exception) {
$drawException = $exception;
}
You have to make a separate script whose only purpose is to display the image, then call that script from the src attribute of the relevant img tag. (A typical practice is to have the image url include some sort of ID in the query string that the image-server script uses to determine what to draw.)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
<?php
// Including all required classes
require_once('class/BCGFontFile.php');
require_once('class/BCGColor.php');
require_once('class/BCGDrawing.php');
// Including the barcode technology
require_once('class/BCGcode39.barcode.php');
$cCode=$_REQUEST['id'];
// Loading Font
$font = new BCGFontFile('./class/font/Arial.ttf', 12);
// The arguments are R, G, B for color.
$color_black = new BCGColor(0, 0, 0);
$color_white = new BCGColor(255, 255, 255);
$drawException = null;
try {
$code = new BCGcode39();
$code->setScale(2); // Resolution
$code->setThickness(20); // Thickness
$code->setForegroundColor($color_black); // Color of bars
$code->setBackgroundColor($color_white); // Color of spaces
$code->setFont($font); // Font (or 0)
$code->parse($cCode); // Text
} catch(Exception $exception) {
$drawException = $exception;
}
/* Here is the list of the arguments
1 - Filename (empty : display on screen)
2 - Background color */
$drawing = new BCGDrawing('', $color_white);
if($drawException) {
$drawing->drawException($drawException);
} else {
$drawing->setBarcode($code);
$drawing->draw();
}
// Header that says it is an image (remove it if you save the barcode to a file)
header('Content-Type: image/png');
// Draw (or save) the image into PNG format.
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
?>
Generate QR-Code and encode barcode to png format
qrcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png
qrcode.drawBarcode("C://vbnet-qrcode.png")
' Print QR-Code to vb.net Bitmap object
Dim qrcodeBitmap As Bitmap
qrcodeBitmap = qrcode.drawBarcode()
Bookmarks