I am doing an inventory control project and i want to create barcodes for the products in addition to the product details in a form.The form values should be submitted to the database to retrieve for future use.How to generate a barcode,how to load it in the database and retrieve it back.can i generate the barcode and submit the form with a single "submit" button?pls guide me in this issue.The following code is used to generate a barcode.i just dont know how to implement it in my form. - <?php
-
//-----------------------------------------------------------------------------
-
// Startup code
-
//-----------------------------------------------------------------------------
-
-
-
if(isset($_GET["text"])) $text=$_GET["text"];
-
if(isset($_GET["format"])) $format=$_GET["format"];
-
if(isset($_GET["quality"])) $quality=$_GET["quality"];
-
if(isset($_GET["width"])) $width=$_GET["width"];
-
if(isset($_GET["height"])) $height=$_GET["height"];
-
if(isset($_GET["type"])) $type=$_GET["type"];
-
if(isset($_GET["barcode"])) $barcode=$_GET["barcode"];
-
-
-
-
-
if (!isset ($text)) $text = 1;
-
if (!isset ($type)) $type = 1;
-
if (empty ($quality)) $quality = 100;
-
if (empty ($width)) $width = 160;
-
if (empty ($height)) $height = 80;
-
if (!empty ($format)) $format = strtoupper ($format);
-
else $format="PNG";
-
-
-
switch ($type)
-
{
-
default:
-
$type = 1;
-
case 1:
-
Barcode39 ($barcode, $width, $height, $quality, $format, $text);
-
break;
-
}
-
-
-
//-----------------------------------------------------------------------------
-
// Generate a Code 3 of 9 barcode
-
//-----------------------------------------------------------------------------
-
function Barcode39 ($barcode, $width, $height, $quality, $format, $text)
-
{
-
switch ($format)
-
{
-
default:
-
$format = "JPEG";
-
case "JPEG":
-
header ("Content-type: image/jpeg");
-
break;
-
case "PNG":
-
header ("Content-type: image/png");
-
break;
-
case "GIF":
-
header ("Content-type: image/gif");
-
break;
-
}
-
-
-
$im = ImageCreate ($width, $height)
-
or die ("Cannot Initialize new GD image stream");
-
$White = ImageColorAllocate ($im, 255, 255, 255);
-
$Black = ImageColorAllocate ($im, 0, 0, 0);
-
//ImageColorTransparent ($im, $White);
-
ImageInterLace ($im, 1);
-
-
-
-
$NarrowRatio = 20;
-
$WideRatio = 55;
-
$QuietRatio = 35;
-
-
-
$nChars = (strlen($barcode)+2) * ((6 * $NarrowRatio) + (3 * $WideRatio) + ($QuietRatio));
-
$Pixels = $width / $nChars;
-
$NarrowBar = (int)(20 * $Pixels);
-
$WideBar = (int)(55 * $Pixels);
-
$QuietBar = (int)(35 * $Pixels);
-
-
-
$ActualWidth = (($NarrowBar * 6) + ($WideBar*3) + $QuietBar) * (strlen ($barcode)+2);
-
-
if (($NarrowBar == 0) || ($NarrowBar == $WideBar) || ($NarrowBar == $QuietBar) || ($WideBar == 0) || ($WideBar == $QuietBar) || ($QuietBar == 0))
-
{
-
ImageString ($im, 1, 0, 0, "Image is too small!", $Black);
-
OutputImage ($im, $format, $quality);
-
exit;
-
}
-
-
$CurrentBarX = (int)(($width - $ActualWidth) / 2);
-
$Color = $White;
-
$BarcodeFull = "*".strtoupper ($barcode)."*";
-
settype ($BarcodeFull, "string");
-
-
$FontNum = 3;
-
$FontHeight = ImageFontHeight ($FontNum);
-
$FontWidth = ImageFontWidth ($FontNum);
-
if ($text != 0)
-
{
-
$CenterLoc = (int)(($width-1) / 2) - (int)(($FontWidth * strlen($BarcodeFull)) / 2);
-
ImageString ($im, $FontNum, $CenterLoc, $height-$FontHeight, "$BarcodeFull", $Black);
-
}
-
else
-
{
-
$FontHeight=-2;
-
}
-
-
-
for ($i=0; $i<strlen($BarcodeFull); $i++)
-
{
-
$StripeCode = Code39 ($BarcodeFull[$i]);
-
-
-
for ($n=0; $n < 9; $n++)
-
{
-
if ($Color == $White) $Color = $Black;
-
else $Color = $White;
-
-
-
switch ($StripeCode[$n])
-
{
-
case '0':
-
ImageFilledRectangle ($im, $CurrentBarX, 0, $CurrentBarX+$NarrowBar, $height-1-$FontHeight-2, $Color);
-
$CurrentBarX += $NarrowBar;
-
break;
-
-
-
case '1':
-
ImageFilledRectangle ($im, $CurrentBarX, 0, $CurrentBarX+$WideBar, $height-1-$FontHeight-2, $Color);
-
$CurrentBarX += $WideBar;
-
break;
-
}
-
}
-
-
-
$Color = $White;
-
ImageFilledRectangle ($im, $CurrentBarX, 0, $CurrentBarX+$QuietBar, $height-1-$FontHeight-2, $Color);
-
$CurrentBarX += $QuietBar;
-
}
-
-
-
OutputImage ($im, $format, $quality);
-
}
-
-
-
//-----------------------------------------------------------------------------
-
// Output an image to the browser
-
//-----------------------------------------------------------------------------
-
function OutputImage ($im, $format, $quality)
-
{
-
switch ($format)
-
{
-
case "JPEG":
-
ImageJPEG ($im, "", $quality);
-
break;
-
case "PNG":
-
ImagePNG ($im);
-
break;
-
case "GIF":
-
ImageGIF ($im);
-
break;
-
}
-
}
-
-
-
//-----------------------------------------------------------------------------
-
// Returns the Code 3 of 9 value for a given ASCII character
-
//-----------------------------------------------------------------------------
-
function Code39 ($Asc)
-
{
-
switch ($Asc)
-
{
-
case ' ':
-
return "011000100";
-
case '$':
-
return "010101000";
-
case '%':
-
return "000101010";
-
case '*':
-
return "010010100"; // * Start/Stop
-
case '+':
-
return "010001010";
-
case '|':
-
return "010000101";
-
case '.':
-
return "110000100";
-
case '/':
-
return "010100010";
-
case '-':
-
return "010000101";
-
case '0':
-
return "000110100";
-
case '1':
-
return "100100001";
-
case '2':
-
return "001100001";
-
case '3':
-
return "101100000";
-
case '4':
-
return "000110001";
-
case '5':
-
return "100110000";
-
case '6':
-
return "001110000";
-
case '7':
-
return "000100101";
-
case '8':
-
return "100100100";
-
case '9':
-
return "001100100";
-
case 'A':
-
return "100001001";
-
case 'B':
-
return "001001001";
-
case 'C':
-
return "101001000";
-
case 'D':
-
return "000011001";
-
case 'E':
-
return "100011000";
-
case 'F':
-
return "001011000";
-
case 'G':
-
return "000001101";
-
case 'H':
-
return "100001100";
-
case 'I':
-
return "001001100";
-
case 'J':
-
return "000011100";
-
case 'K':
-
return "100000011";
-
case 'L':
-
return "001000011";
-
case 'M':
-
return "101000010";
-
case 'N':
-
return "000010011";
-
case 'O':
-
return "100010010";
-
case 'P':
-
return "001010010";
-
case 'Q':
-
return "000000111";
-
case 'R':
-
return "100000110";
-
case 'S':
-
return "001000110";
-
case 'T':
-
return "000010110";
-
case 'U':
-
return "110000001";
-
case 'V':
-
return "011000001";
-
case 'W':
-
return "111000000";
-
case 'X':
-
return "010010001";
-
case 'Y':
-
return "110010000";
-
case 'Z':
-
return "011010000";
-
default:
-
return "011000100";
-
}
-
}
-
-
-
?>
7 4836 Dormilich 8,658
Recognized Expert Moderator Expert
How to generate a barcode,how to load it in the database and retrieve it back.can i generate the barcode and submit the form with a single "submit" button?pls guide me in this issue.The following code is used to generate a barcode.i just dont know how to implement it in my form.
- As I see it the script will do that
- the barcode is a picture (thus binary content)
- dito (but I think it's a good idea to store the actual value too)
- first submit, then generate (and do all the stuff you want with the barcode)
- what is the form expected to do?
regards
- As I see it the script will do that
- the barcode is a picture (thus binary content)
- dito (but I think it's a good idea to store the actual value too)
- first submit, then generate (and do all the stuff you want with the barcode)
- what is the form expected to do?
regards
The form is used to load the required details like cost price,selling price,discounts allowed,etc..fo r the new product which should be retrieved back from the database once when the id of that product is given including the barcode.what value should i give to generate a barcode?
dlite922 1,584
Recognized Expert Top Contributor
The form is used to load the required details like cost price,selling price,discounts allowed,etc..fo r the new product which should be retrieved back from the database once when the id of that product is given including the barcode.what value should i give to generate a barcode?
That's easy: a value that uniquely identifies that item, such as a product number or product ID.
This is a great idea. It really stretches the limit on what you could do with a PHP application. After so many years, people still don't fully understand the possibilities and capabilites of PHP.
Dan
code green 1,726
Recognized Expert Top Contributor
I might be missing something but what use is a barcode on a web page?
And why store it as a JPEG etc?
Barcodes are read by barcode scanners.
Is somebody going to to be waving a scanner in front of a monitor?
I am asking because I don't want divyac producing something impractical (unless this is just for fun).
I have written php scripts that generate barcodes onto packing lists, stock control proformas etc.
And as barcodes are usually!?! on paper the output was done on PDF (FPDF class).
In this case a barcode is simply a font, so you don't need a picture of anything,
simply a font file
I might be missing something but what use is a barcode on a web page?
And why store it as a JPEG etc?
Barcodes are read by barcode scanners.
Is somebody going to to be waving a scanner in front of a monitor?
I am asking because I don't want divyac producing something impractical (unless this is just for fun).
I have written php scripts that generate barcodes onto packing lists, stock control proformas etc.
And as barcodes are usually!?! on paper the output was done on PDF (FPDF class).
In this case a barcode is simply a font, so you don't need a picture of anything,
simply a font file
My client asked this work in a very simple way and in a very short period.so i haven't tried out PDF generation.I think he would take the print of the barcode from the web page itself.
Also,once I generated a PDF document but when i tried to open that document it showed some error and i couldn't open it.Can you just guide me through in this issue??
Thanks
Divya
code green 1,726
Recognized Expert Top Contributor
I have only written PDF docs using an open source class FPDF FPDF I also know of ezPDF.
Creating PDF is slow and fiddly, but so is any programming requiring a printout.
People think it is simple only because they have been spoilt with microsoft office
Printing from a web page has hidden problems (size, browser variations etc)
whereas PDF is precise.
Take a look at the FPDF site and see what you think
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tom Turner |
last post by:
Here's the background on my situation. The question follows ---
We have 600 units of mail going from our business to various Post
Offices every morning. Every unit is accompanied by a paper
Verification form which is signed and dated by a postal employee
and returned to our office as proof of delivery.
The Verification contains a 24 character barcode which holds a
non-unique 5 digit postal zip code at pos 5-9, and a unique 10-
digit...
|
by: |
last post by:
Hi all, we have a need to barcode encode and display a record identifier
(number) both in html in the browser and through fdf in adobe acrobat in
realtime. Is this possible? Can anyone make any recommendations on software
to do this?
thanks!
|
by: Samuel Shulman |
last post by:
I would like to add barcode functionality to my POS program
How does one attach barcode reader is it usually USB port
How can the program get the data read by the device
Thank you,
Samuel
|
by: Dilip |
last post by:
hi ppl ,
i need some help in generating barcode text thro FOP ..
i am succesfull in creating a input number as a barcode value..
but the problem is i need the barcode to be displayed vertically
i have used code-39-30 font . created an xml document for the font
that is a font file metrics..
is there any way to display the text vertically
|
by: =?Utf-8?B?cGF0cmlja2RyZA==?= |
last post by:
Hi everyone!
Does anyone know what do I need (control or anything else) in order to
provide it with a number (fixed digits) and let it created a barcode for me,
which I could scan later using a scanner and produce that number back?
Thanks in advance!
| |
by: Alper Ozgur |
last post by:
Hi;
How can i capture and decode the barcode that reading by an usb Barcode
reader?
|
by: wassimdaccache |
last post by:
Hello everybody
Does someone have a VB module and FONT for windows XP SP2 to import into a MSaccess (2003) to print a barecode ...
Please leave me any comments about barecode generation or anything u know about barecode...
|
by: jim |
last post by:
I need to have 2 simple barcode reader applications finished by midnight
tonight. I have never written any barcode reader software and need any help
that you may be able to offer.
I do not know what type of barcode the user will have, so I need to be able
to accept input from any industry standard barcode reader.
I need to check the barcodes scanned to see if they are in a database of
acceptable barcodes and simply show ACCEPT or...
|
by: Robocop |
last post by:
Does anyone know of any decent (open source or commercial) python
barcode recognition tools or libraries. I need to read barcodes from
pdfs or images, so it will involve some OCR algorithm. I also only
need to read the code 93 symbology, so it doesn't have to be very
fancy. The most important thing to me is that it outputs in some
python friendly way, or ideally that it is written in python. Any
tips would be great!
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |