问题
This is my first post on this website, can't seem to solve the problem.
How do I emulate key function Ctrl+B to a barcode so i can scan the barcode with a scanner without pressing Ctrl+B. I've tried reading the ASCII Control Codes ASCII control codes Please help me.
回答1:
As one of your tags demonstrates, you are already aware of the code 128 symbology. You will want to use the code128A start code (103) and the same character as a lower case 'b' in code128B (66). Finally, after adding additional data, properly calculate the checksum and add it as well as the stop code (106). The following HTML illustrates:
<img
alt="103,{Start A}" title="103,{Start A}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AC9gAMEAkBQ+aMgAAAAASUVORK5CYII=" width="20" height="40"><img
alt=" 66,A:{STX},B:{b}" title=" 66,A:{STX},B:{b}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AG8gAQEAkGqGy8gAAAAASUVORK5CYII=" width="20" height="40"><img
alt=" 52,A:{T},B:{T}" title=" 52,A:{T},B:{T}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ACOgAOkAxNCxwt0AAAAASUVORK5CYII=" width="20" height="40"><img
alt=" 37,A:{E},B:{E}" title=" 37,A:{E},B:{E}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AHLgAccBU7KPeu8AAAAASUVORK5CYII=" width="20" height="40"><img
alt=" 51,A:{S},B:{S}" title=" 51,A:{S},B:{S}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ACLgAScBA3yI80wAAAAASUVORK5CYII=" width="20" height="40"><img
alt=" 52,A:{T},B:{T}" title=" 52,A:{T},B:{T}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ACOgAOkAxNCxwt0AAAAASUVORK5CYII=" width="20" height="40"><img
alt=" 24,A:{8},B:{8}" title=" 24,A:{8},B:{8}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ABZgAI8Ad3Mh6bwAAAAASUVORK5CYII=" width="20" height="40"><img
alt="106,{Stop}"title="106,{Stop}"src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAABAQMAAAA/57ZEAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADigARMA2dpJzT8AAAAASUVORK5CYII=" width="20" height="40">
To test, open up Wordpad or any word processor that uses 'Ctrl-B' to switch bold text on and off. Scan a printed copy of the barcode in the snippet. You should see the text "TEST" alternate between bold and plain styles each time you scan.
<img
alt="103,{Start A}" title="103,{Start A}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AC9gAMEAkBQ+aMgAAAAASUVORK5CYII=" width="12" height="33"><img
alt=" 66,A:{STX},B:{b}" title=" 66,A:{STX},B:{b}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AG8gAQEAkGqGy8gAAAAASUVORK5CYII=" width="12" height="33"><img
alt=" 66,A:{STX},B:{b}" title=" 66,A:{STX},B:{b}" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAABAQMAAAAy+cYDAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/AG8gAQEAkGqGy8gAAAAASUVORK5CYII=" width="12" height="33"><img
alt="106,{Stop}"title="106,{Stop}"src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAABAQMAAAA/57ZEAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAADklEQVQIHQEDAPz/ADigARMA2dpJzT8AAAAASUVORK5CYII=" width="12" height="33">
来源:https://stackoverflow.com/questions/45222061/how-do-i-emulate-key-function-ctrl-b-to-a-barcode