我一直在寻找128格式条形码的字体,以便使用PDFlib放置在PDF中。我到处寻找,似乎无法找到一个适用于我的扫描仪。尝试扫描时似乎没有识别条形码。
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;
这实际上输出条形码但扫描仪无法读取
答案 0 :(得分:1)
您是否将Start(104),Checksum(75)和Stop(106)代码输出到该页面?如果您使用Code 128B,则条形码应与以下HTML生成的条形码类似。
< IMG ALT = “104,{开始B}” 标题= “104,{开始B}” SRC = “数据:图像/ PNG; BASE64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy + cYDAAAABlBMVEUAAAD /// + l2Z / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / AC3gAT0BDuLeG4IAAAAASUVORK5CYII =” 宽度= “15”高度= “30” >< IMG alt =“34,A:{B},B:{B}”title =“34,A:{B},B:{B}”src =“data:image / png; base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy + cYDAAAABlBMVEUAAAD // / + l2Z / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / AHTgAcsBVYSvxaMAAAAASUVORK5CYII =“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 / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / ACNgAKkAhD / i5lYAAAAASUVORK5CYII =“width =”15“height =”30“>< img alt =“20,A:{4},B:{4}”title =“20,A:{4},B:{4}”src =“data:image / png; base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy + cYDAAAABlBMVEUAAAD // / + l2Z / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / ADYgAI8AVxcQlAsAAAAASUVORK5CYII =“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 / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / 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 / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / ACNgAKkAhD / i5lYAAAAASUVORK5CYII =“width =”15“height =”30“>< img alt =“20,A:{4},B:{4}”title =“20,A:{4},B:{4}”src =“data:image / png; base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy + cYDAAAABlBMVEUAAAD // / + l2Z / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / ADYgAI8AVxcQlAsAAAAASUVORK5CYII =“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 / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / 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 / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / ACNgAKkAhD / i5lYAAAAASUVORK5CYII =“width =”15“height =”30“>< img alt =“20,A:{4},B:{4}”title =“20,A:{4},B:{4}”src =“data:image / png; base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy + cYDAAAABlBMVEUAAAD // / + l2Z / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / ADYgAI8AVxcQlAsAAAAASUVORK5CYII =“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 / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / 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 / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / ACNgAKkAhD / i5lYAAAAASUVORK5CYII =“width =”15“height =”30“>< img alt =“20,A:{4},B:{4}”title =“20,A:{4},B:{4}”src =“data:image / png; base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy + cYDAAAABlBMVEUAAAD // / + l2Z / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / ADYgAI8AVxcQlAsAAAAASUVORK5CYII =“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 / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / ADFgAMUAksTlwtMAAAAASUVORK5CYII =“width =”15“height =”30“>< img alt =“75,A:{VT},B:{k}”title =“75,A:{VT},B:{k}”src =“data:image / png; base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy + cYDAAAABlBMVEUAAAD // / + l2Z / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / AD2gAR0A3h5 + 5CUAAAAASUVORK5CYII =“width =”15“height =”30“>< img ALT = “106,{停止}” 标题= “106,{停止}” SRC = “数据:图像/ PNG; BASE64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAABAQMAAAA / 57ZEAAAABlBMVEUAAAD /// + l2Z / dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz / ADigARMA2dpJzT8AAAAASUVORK5CYII =” 宽度= “15” 高度= “30” >