0
<?php
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<!--<img src="D:/wamp/www/docx/tenh.jpg" style="" width="200px"/>-->
    <div id="demo"></div>
    <script src="jquery-latest.min.js"></script>
    <script src="jquery-barcode.js"></script>
    <script>
$("#demo").barcode(
"1234567890128", // Value barcode (dependent on the type of barcode)
"ean13" // type (string)
);
</script>
</body>
</html>

After i run this above code i get one word file but when i open it, i don't see bardcode in the word document. Why? How can i solve this problem?

2
Contributors
1
Reply
16
Views
3 Years
Discussion Span
Last Post by diafol
0
<?php
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");

//Change the directory to your own...
$localRoot = "file:///C|/xampp/htdocs/newdwapi/barcodes";

$filename = "img_" . time() . ".gif";
$barcode = "37348678";

require "php-barcode.php";

$im     = imagecreatetruecolor(300, 300);  
$black  = ImageColorAllocate($im,0x00,0x00,0x00);  
$white  = ImageColorAllocate($im,0xff,0xff,0xff);  
imagefilledrectangle($im, 0, 0, 300, 300, $white);  

$data = Barcode::gd($im, $black, 150, 150, 0, "code128", $barcode, 2, 50);  

    function outputImage($im)
    {
        ob_start();
        imagegif($im);
        $content = ob_get_contents();
        ob_end_clean();
        return $content;
    }

$imgout = outputImage($im);
file_put_contents("barcodes/$filename",$imgout);
imagedestroy($im);

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
</head>
<body>
<h1>Here's my Barcode</h1>
<img src="<?php echo $localRoot .'/'. $filename;?>" />
</body>
</html>

The php version seems to work well - although the html page doesn't show the image - the word document does. Note the use of the php class - not the javascript version.

42b2faaa832459dd3e58c98a77bffa12

Edited by diafol

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.