0

我一直在寻找 128 格式条形码的字体,以使用 PDFlib 放置在 PDF 中。Iv 到处找,似乎找不到适合我的扫描仪的。尝试扫描时似乎无法识别条形码。

Iv 使用了 code128.tff、ADVC128C.TFF 和 ADVC128B.ttf 字体,虽然它们似乎在输出条形码,但似乎没有扫描仪识别它。有没有人对此有任何运气,或者你知道我在哪里可以找到更多字体来试用。

以下是我的代码。

$p = new PDFlib();

$p->set_option("errorpolicy=return");
$p->set_option("stringformat=utf8");

if ($p->begin_document($outfile, "") == 0)
throw new Exception("Error: " . $p->get_errmsg());

/* Start page */
$p->begin_page_ext(0, 0, "width=300 height=300");

$p->set_option("FontOutline={Code128bWin=/data/Code128bWin.ttf}");

$font = $p->load_font("Code128bWin", "unicode", "");
if ($font == 0)
throw new Exception("Error: " . $p->get_errmsg());

$p->setfont($font, 20);
$p->fit_textline("B546546546546", $x, $y-=20, "");


$p->set_option("FontOutline={Code128bWinLarge=/data/Code128bWinLarge.ttf}");
$font = $p->load_font("Code128bWinLarge", "unicode", "");
if ($font == 0)
throw new Exception("Error: " . $p->get_errmsg());

$p->setfont($font, 20);
$p->fit_textline("B546546546546", $x, $y-=60, "");

/* Finish page */
$p->end_page_ext("");

$p->end_document("");

$buf = $p->get_buffer();
$len = strlen($buf);

header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=font_resource.pdf");
print $buf;

这实际上输出了条形码,但扫描仪无法读取

4

1 回答 1

1

您是否将开始 (104)、校验和 (75) 和停止 (106) 代码输出到页面?如果您使用 Code 128B,您的条码应该看起来像由以下 HTML 生成的条码。

<img alt="104,{开始 B}" title="104,{开始 B}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AC3gAT0BDULeG4IAAAASUVII宽度=" 15" height="30"><img alt=" 34,A:{B},B:{B}" title=" 34,A:{B},B:{B}" src="data:image /png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AHTgAcsBVYSvxaMAAAAASUVORK5CYII="width="15" height="30"><img alt="21,A:{5}"title:{ ="21,A:{5},B:{5}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ACNgAKkAhD/i5lYAAAAAASUVORK5CYII="width="15" height="30"><img alt="20,A:{4},B:{4} ,A:{4},B:{4}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADYgAI8AVxcQlAsAAAAAASUVORK5CYII="width="height="" img alt="22,A:{6},B:{6}" title="22,A:{6},B:{6}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD/ //+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADFgAMUAksTlwtMAAAAASUVORK5CYII="width="15" height="30"><img alt="21,A:{5},B:{5}"title=" 21,A:{5},B:{5}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ACNgAKkAhD/i5lYAAAAASUVORK5CY15"height ="30"><img alt="20,A:{4},B:{4}" title="20,A:{4},B:{4}" src="data:image/png; base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADYgAI8AVxcQlAsAAAASUVORK5CYII="width="15" height="30"><img alt="26}"title:{2},B ,A:{6},B:{6}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADFgAMUAksTlwtMAAAAASUVORK5CYII="width="15"height="30"><img alt="21,A:{5},B:{5}" title="21,A:{5},B:{5}" src="data:image/png ;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ACNgAKkAhD/i5lYAAAAAASUVORK5CYII="width="15" height="30"><img alt="20,A:{4},B4} =" 20,A:{4},B:{4}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADYgAI8AVxcQlAsAAAAAAASUVORK5CYII="宽度" "><img alt="22,A:{6},B:{6}" title="22,A:{6},B:{6}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADFgAMUAksTlwtMAAAAASUVORK5CYII="width="15" height="30"><img alt="21,A:{5},B:{5}" :{5},B:{5}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ACNgAKkAhD/i5lYAAAAAASUVORK305CYII="width="1 img alt="20,A:{4},B:{4}" title="20,A:{4},B:{4}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD/ //+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADYgAI8AVxcQlAsAAAAAASUVORK5CYII=" width="15" height="30"><img alt=" 22,A:{6},B:{6}"title=" 22,A:{6},B:{6}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADFgAMUAksTlwt15AAAASUVORK5CYII 宽度30"><img alt="75,A:{VT},B:{k}" title="75,A:{VT},B:{k}" src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AD2gAR0A3h5+5CUAAAAAASUVORK5CYII="width="15" height="30"><img alt="106,{Stop}"title="106,"数据:图像/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAABAQMAAAA/57ZEAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADigARMA2dpJzT8AAAAASUVORK5CYII="width="15" height="30">

于 2013-06-06T12:11:59.567 回答