Jump to content

BJettkant

Members
  • Posts

    1
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

BJettkant's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. How can I print bar codes (code 128) into a pdf? I use barcode128.au3 for generating the Code 128 string from my input string (patient name etc.) #include <barcode128.au3> ; Much thancs to Zedna for duing this work and sharing it. First of all I install the true type font code128.ttf with font name "Code 128" as a Win10 font. Next I include in the MPDFF_UDF.au3 V103 the missing function _Iif and get the Example_Mixed.au3 running. After this I tried to include the "Code 128" font: ; constant string as new font name: Global $PDF_FONT_CODE128 = "Code 128" ; setting the font name _LoadFontTT("_Code128", $PDF_FONT_CODE128) ; genrat test string:     $stOut = ""     For $i=32 To 64         $stOut = $stOut & Chr($i)     Next ; start a pdf page as in the example: Example_Mixed.au3    and change pdf content to: _BeginPage()         ;put some text etc.     _SetColourFill(0x000000)     _DrawText(3, 20,  $stOut, "_Courier", 12, $PDF_ALIGN_LEFT, 0)     _DrawText(3, 16,  $stOut, "_Code128", 12, $PDF_ALIGN_LEFT, 0) _EndPage() But the result is always a ASCII Char Array: !"#$%&'()*+,-./0123456789:;<=>?@, not a series of bar code letters. How to install and use the font "Code 128" corectly to generate a pdf? My changes in MPDFF_UDF: ; include style etc., same parameter used as at function __FontCourier Func __FontCode128($Style = $PDF_FONT_NORMAL)     $BaseFont = "Code 128"     $FirstChar = 32     $LastChar = 255     $MissingWidth = 600     Local $aTemp[$LastChar - $FirstChar]; + 1]     Switch $Style         Case $PDF_FONT_NORMAL             $aTemp = StringSplit("600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, " & _             "600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, " & _             "600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, " & _             "600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, " & _             "600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, " & _             "600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, " & _             "600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, " & _             "600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600", ", ", 3)             $Param = "/Flags 34 /FontBBox [-250 -300 720 1000] " & _                     "/MissingWidth 600 /StemV 109 " & _                     "/StemH 109 /ItalicAngle 0 /CapHeight 833 /XHeight 417 " & _                     "/Ascent 833 /Descent -300 /Leading 133 " & _     ;...the othet 2 cases are simelar     EndSwitch     For $i = $FirstChar To $LastChar         $Widths[$i] = $aTemp[$i - $FirstChar]     Next     Local $aRetTmp[6] = [$BaseFont, $FirstChar, $LastChar, $Param, $Widths, $MissingWidth]     Return $aRetTmp EndFunc   ;==>__FontCode128 ; add the new case in _loadFont  Func _LoadFontTT($sAlias, $BaseFont, $sOptions = $PDF_FONT_NORMAL)     Local $sTemp = ""     $_Font = $_Font + 1     $BaseFont = StringReplace($BaseFont, " ", "")     Switch $BaseFont         Case "TimesNewRoman"             __FontTimes($sOptions)         Case "CourierNew"             __FontCourier($sOptions)         Case "Code128"             __FontCode128($sOptions) ; it this seem that this is not working corectly         Case "Symbol"             __FontSymbol($sOptions)         Case "Calibri"             __FontCalibri($sOptions)         Case "Garamond"             __FontGaramond($sOptions)         Case Else             __FontArial($sOptions)     EndSwitch     Local $i = __InitObj()     __ToBuffer("<< /Type/Font/Subtype/TrueType/Name/" & $sAlias & "/BaseFont/" & $BaseFont & $sOptions & "/FirstChar " & $FirstChar & "/LastChar " & $LastChar & "/FontDescriptor " & $i + 1 & " 0 R/Encoding/WinAnsiEncoding/Widths [")     For $j = $FirstChar To $LastChar         If $Widths[$j - $FirstChar] <> 0 Then             $sTemp &= __ToStr($Widths[$j - $FirstChar]) & " "             If Mod($j - $FirstChar + 1, 16) = 0 Or $j = $LastChar Then                 __ToBuffer($sTemp)                 $sTemp = ""             EndIf         EndIf     Next     __ToBuffer("] >>")     __EndObj()     $_sFONT = $_sFONT & "/" & $sAlias & " " & $i & " 0 R " & @CRLF     $_sFONTNAME = $_sFONTNAME & "<" & $sAlias & ">" & StringRight("0000" & $_Font, 4) & ";"     ;$i =     __InitObj()     __ToBuffer("<< /Type/FontDescriptor/FontName/" & $BaseFont & $Param & ">>")     __EndObj() EndFunc   ;==>_LoadFontTT
×
×
  • Create New...