0.1.2 • Published 6 months ago

react-native-multi-bluetooth-printer v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

react-native-multi-bluetooth-printer

react native library for printer bluetooth multi devices

Installation

npm install react-native-multi-bluetooth-printer
yarn add react-native-multi-bluetooth-printer

Usage

import * as React from 'react';

import { StyleSheet, View, Text, Button } from 'react-native';
import MultiBluetoothPrinter from 'react-native-multi-bluetooth-printer';

export default function App() {

  const [printer, setPrinter] = React.useState([])

// getBluetoothDevice enable or not enable
  const getBluetoothIsEnabled = async () => {
    await MultiBluetoothPrinter.isBluetoothEnabled().then((granted) => {
      if (granted) {
        alert("Your Bluetooth is Enable")
      }
      else {
        alert("Your Bluetooth is Disabled")
      }
   }, (err) => {
      alert(err)
   })
  }

// getListBluetoothDevice connected (if not connect, connect manual in your android)
  const getListsBloetoothDeviceLists = async () => {
    await MultiBluetoothPrinter.listsBloetoothDeviceLists().then((lists) => {
      console.log(JSON.stringify(lists));
      setPrinter(lists)
    }) 
  }

// print for multi or one device
  const handleMultiPrint = async () => {
    for (let i = 0; i < printer.length; i++ ) {
      let params = {
        payload : 
        "[C]<img>your image url</img>"
        "[L]\n" +
        "[C]<u><font size='big'>ORDER N°045</font></u>\n" +
        "[L]\n" +
        "[C]================================\n" +
        "[L]\n" +
        "[L]<b>BEAUTIFUL SHIRT</b>[R]9.99e\n" +
        "[L]  + Size : S\n" +
        "[L]\n" +
        "[L]<b>AWESOME HAT</b>[R]24.99e\n" +
        "[L]  + Size : 57/58\n" +
        "[L]\n" +
        "[C]--------------------------------\n" +
        "[R]TOTAL PRICE :[R]34.98e\n" +
        "[R]TAX :[R]4.23e\n" +
        "[L]\n" +
        "[C]================================\n" +
        "[L]\n" +
        "[L]<font size='tall'>Customer :</font>\n" +
        "[L]Raymond DUPONT\n" +
        "[L]5 rue des girafes\n" +
        "[L]31547 PERPETES\n" +
        "[L]Tel : +33801201456\n" +
        "[L]\n" +
        "[C]<barcode type='ean13' height='10'>831254784551</barcode>\n" +
        "[L]\n" +
        "[C]<qrcode size='20'>https://dantsu.com/</qrcode>\n",
        deviceAddress: printer[i].deviceAddress
      }

      await MultiBluetoothPrinter.printBluetoothSelectDevice(params).then(() => alert('Success'))
      .catch ((e) => {
        alert(JSON.stringify(e))
      })
    }
  }

  return (
    <View>
      <Button
        tittle={'Test Bluetooth Enable'}
        onPress={() => getBluetoothIsEnabled()}
      />
      <View style={{marginBottom: 16}} />
      <Button
        tittle={'get Lists Connected Device'}
        onPress={() => getListsBloetoothDeviceLists()}
      />
      <View style={{marginBottom: 16}} />
      <Button
        tittle={'Test Multi Print'}
        onPress={() => handleMultiPrint()}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  box: {
    width: 60,
    height: 60,
    marginVertical: 20,
  },
});

Payload

same as https://github.com/DantSu/ESCPOS-ThermalPrinter-Android/tree/3.0.1#formatted-text--syntax-guide except for the <img></img> tag

place the image url directly between the img tags

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

JSONStreamabbrevabort-controlleracornacceptsacorn-walkadd-streamajvaggregate-erroranseragent-baseansi-regexansi-alignansi-fragmentsansi-stylesacorn-jsxansi-escapesappdirsjsanymatchargarray-ifyargparsearray-includesarray-buffer-byte-lengtharray-unionarray.prototype.findlastarray.prototype.flatarray.prototype.flatmaparraybuffer.prototype.slicearrifyarray.prototype.tosortedarray.prototype.toreversedast-typesasapasync-retryarray.prototype.mapbabel-coreastral-regexasync-limiterbabel-jestbabel-plugin-istanbulbabel-plugin-polyfill-corejs2babel-plugin-jest-hoistbabel-plugin-polyfill-regeneratoravailable-typed-arraysbabel-plugin-polyfill-corejs3base64-jsbabel-plugin-transform-flow-enumsbalanced-matchbasic-ftpbefore-after-hookbabel-preset-current-node-syntaxblbig-integerbplist-parserboxenbabel-preset-jestbrowserslistbufferbuffer-frombracescacachecacheable-requestbytesbundle-namecall-bindcaller-callsitebserbrace-expansioncallsitescacheable-lookupcaniuse-litechalkcamelcasecaller-pathchar-regexchownrcjs-module-lexerchardetcamelcase-keyschrome-launchercli-cursorclean-stackci-infocli-spinnerscliuicli-widthcocli-boxesclonecommanderclone-deepcommand-existscollect-v8-coveragecolor-namecolor-convertcompare-funccolorettecompressibleconcat-mapconcat-streamconfigstorecompressionconventional-changelog-angularconfig-chainconnectcommondirconventional-changelog-codemirrorconventional-changelog-conventionalcommitsconventional-changelogconventional-changelog-emberconventional-changelog-eslintconventional-changelog-atomconventional-changelog-coreconventional-changelog-jshintconventional-changelog-jqueryconventional-changelog-preset-loaderconventional-commits-filterconventional-commits-parserconventional-changelog-writerconventional-recommended-bumpcore-js-compatcore-util-iscosmiconfigcosmiconfig-typescript-loaderconventional-changelog-expresscreate-jestcreate-requireconvert-source-mapcross-spawndata-uri-to-bufferdata-view-bufferdargsdata-view-byte-lengthcrypto-random-stringdateformatdayjscsstypedecamelize-keysdata-view-byte-offsetdebugdecompress-responsedecamelizededentdeep-isdeepmergedefaultsdefault-browser-iddefault-browserdefine-data-propertydefer-to-connectdefine-propertiesdeldegeneratordenodeifydefine-lazy-propdeprecationdetect-newlinedepddiffdestroydir-globdot-propdiff-sequencesee-firsteastasianwidthdoctrineelectron-to-chromiumemitteryemoji-regexencodeurlencodingend-of-streamenv-pathserr-codeerrorhandlerenvinfoerror-exerror-stack-parseres-abstractes-array-method-boxes-properlyes-errorses-get-iteratores-object-atomses-set-tostringtagescaladees-define-propertyes-shim-unscopablesescape-goatdeep-extendes-iterator-helpersescape-htmlescodegeneslint-plugin-eslint-commentseslint-plugin-jesteslint-plugin-ft-floweslint-plugin-reacteslint-plugin-react-native-globalseslint-plugin-react-hookseslint-plugin-react-nativeeslint-visitor-keyseslint-scopeespreeesprimaesqueryesrecurseestraverseetagevent-target-shimesutilsexitexternal-editorexecafast-deep-equalfast-diffexpectfast-levenshteinfast-globfast-json-stable-stringifyexponential-backofffast-xml-parserfb-watchmanfastqfill-rangefiguresfile-entry-cachefetch-blobfinalhandlerflattedfind-cache-dirfind-upflat-cacheforeground-childfor-eachform-data-encoderfreshformdata-polyfillflow-parserfs-extraflow-enums-runtimefs.realpathfseventsfunction-bindfs-minipassfunctions-have-nameses-to-primitiveget-intrinsicgensyncget-package-typeget-symbol-descriptionget-streamescape-string-regexpgit-raw-commitsget-urigit-upgit-remote-origin-urlgitconfiglocalgit-semver-tagsgit-url-parseglobget-pkg-repoglobal-dirsfunction.prototype.nameglobalsgopdglobbygotglobalthishard-rejectionget-caller-filegraphemerhandlebarshas-property-descriptorshas-bigintsgraceful-fsglob-parenthas-yarnhas-protohas-tostringtaghermes-estreehermes-profile-transformerhasownhermes-parserhosted-git-infohas-flaghas-symbolshttp-cache-semanticshtml-escaperhttp-errorshttps-proxy-agenthuman-signalshttp2-wrappericonv-liteieee754ignoreimport-freshimage-sizehttp-proxy-agentimurmurhashimport-localindent-stringinflightinheritsiniinquirerinternal-slotinvariantipip-addressimport-lazyis-array-bufferis-argumentsinterpretis-absoluteis-async-functionis-boolean-objectis-ciis-callableis-arrayishis-core-moduleis-directoryis-data-viewis-dockeris-extglobis-finalizationregistryis-fullwidth-code-pointis-bigintis-generator-fnis-git-repositoryis-date-objectis-generator-functionis-git-dirtyis-installed-globallyis-inside-containeris-globis-lambdais-interactiveis-mapis-numberis-path-cwdis-number-objectis-path-insideis-objis-plain-objis-plain-objectis-regexis-relativeis-setis-shared-array-bufferis-negative-zerois-streamis-sshis-symbolis-text-pathis-stringis-unc-pathis-npmis-typedarrayis-typed-arrayis-windowsis-weakrefis-weakmapis-weaksetisarrayis-yarn-globalisobjectis-unicode-supportedissue-parseristanbul-lib-coverageistanbul-lib-instrumentistanbul-lib-source-mapsistanbul-lib-reportiterate-valueisexeiterate-iteratoristanbul-reportsjackspeakjest-changed-filesiterator.prototypejest-clijest-circusjest-docblockjest-eachjest-diffjest-configjest-environment-nodeis-wsljest-get-typejest-leak-detectorjest-pnp-resolverjest-mockjest-message-utiljest-matcher-utilsjest-resolve-dependenciesjest-runnerjest-resolvejest-regex-utiljest-runtimejest-validatejest-utiljest-watcherjest-workerjsbnjsc-androidjs-tokensjs-yamljsc-safe-urljoijson-bufferjscodeshiftjsescjson-schema-traversejson-parse-even-better-errorsjest-haste-mapjson-parse-better-errorsjson-stringify-safejson-stable-stringify-without-jsonifyjson5jsonfilejsx-ast-utilsjest-snapshotkeyvkleurkind-oflevnlatest-versionlines-and-columnsload-json-filelighthouse-loggerlodash.camelcasejsonparselodash.escaperegexplevenlodash.kebabcaselodashlodash.isstringlodash.ismatchlodash.mergelodash.isplainobjectlocate-pathlodash.mergewithlodash.debouncelodash.snakecaselodash.startcaselodash.uniqlodash.uniqbylodash.upperfirstlodash.capitalizelog-symbolslogkittyloose-envifylodash.throttlelowercase-keyslru-cachemacos-releasemake-fetch-happenlodash.isfunctionmake-errormap-objmake-dirmakeerrormerge-streammarkymeowmemoize-onemetro-cache-keymetro-babel-transformermetro-cachemetro-configmerge2metrometro-coremetro-minify-tersermetro-runtimemetro-symbolicatemetro-transform-pluginsmetro-transform-workermicromatchmimemimic-fnmetro-source-mapmimic-responsemime-typesminimatchmime-dbmin-indentmetro-file-mapminimistminipass-fetchminipass-flushminipass-sizedminimist-optionsminipassminizlibminipass-collectnatural-comparemkdirpmsmodify-valuesmute-streamnegotiatormetro-resolverneo-asyncnew-github-release-urlnode-dirnocachenatural-compare-litenode-domexceptionnode-fetchnode-int64node-forgenode-abort-controllernode-gypnoptnode-stream-zipnormalize-package-datanormalize-pathminipass-pipelinenormalize-urlnetmasknode-releasesob1npm-run-pathobject-inspectnullthrowsobject-assignobject-keysobject.assignobject.entriesobject.fromentriesobject.valuesobject.hasownonetimeoptionatoronceon-finishedos-namep-cancelablep-mapp-limitp-locateopenp-tryparent-modulepackage-jsonpac-resolverpac-proxy-agentparse-jsonparse-pathparse-urlorapath-existson-headersparseurlpath-parseos-tmpdirpath-is-absolutepath-typepath-keypicocolorspath-scurrypiratespicomatchpkg-dirprelude-lspossible-typed-array-namespifyproc-logprettier-linter-helpersprocess-nextick-argspromise-retrypretty-formatpromisepromise.allsettledprotocolsprop-typesproto-listproxy-agentpunycodepromptspupaqpure-randquerystringqueue-microtaskpumpqueuerange-parserproxy-from-envrcreact-refreshreact-isquick-lrureadable-streamread-pkg-upread-pkgrecastrechoirreact-shallow-rendererredentregeneratereadlinereflect.getprototypeofregenerator-transformreact-devtools-coreregexp.prototype.flagsregexpu-coreregistry-auth-tokenregistry-urlregenerate-unicode-propertiesregjsparserrequire-from-stringrequire-directoryrequire-main-filenameresolveresolve-alpnresolve-globalresolve-fromreusifyresolve.exportsrestore-cursorrun-parallelregenerator-runtimerun-asyncresolve-cwdrun-applescriptretryrxjsresponselikesafe-regex-testsafer-bufferselfsignedschedulerserialize-errorset-blockingsemver-diffsendrimrafsafe-bufferset-function-lengthserve-staticsetprototypeofshebang-commandshelljssisteransishell-quoteside-channelsafe-array-concatslashslice-ansisocks-proxy-agentsmart-buffersemversource-map-supportshallow-clonesource-mapset-function-namespdx-expression-parsesocksshebang-regexspdx-exceptionssprintf-jsssrisignal-exitsplit2splitspdx-correctstack-utilsstatusesstacktrace-parserstop-iteration-iteratorstring-lengthstdin-discarderstackframespdx-license-idsstring-widthstring.prototype.matchallstring-width-cjsstring-natural-comparestring.prototype.trimstartstring.prototype.trimendstrip-bomstrip-final-newlinestrip-ansi-cjsstrnumstrip-ansistrip-json-commentsstrip-indentsudo-promptstring_decodertemptemp-dirsupports-colortartext-extensionstersersupports-preserve-symlinks-flagtest-excludetext-tablethroatthrough2titleizetmptoidentifierto-fast-propertiesstring.prototype.trimto-regex-rangethroughtr46trim-newlinestslibtsutilstmplturbo-darwin-64type-checktype-festtype-detecttyped-array-bufferts-nodetyped-array-byte-lengthtypedarraytyped-array-lengthuglify-jstyped-array-byte-offsetsynckitunicode-property-aliases-ecmascriptundici-typesunbox-primitiveunicode-canonical-property-names-ecmascriptunique-filenameunicode-match-property-ecmascriptunc-path-regexunique-slugunpipeunique-stringunicode-match-property-value-ecmascripttypedarray-to-bufferuniversalifyupdate-notifierurl-joinutil-deprecateuri-jsv8-compile-cache-libutils-mergev8-to-istanbulvlqvalidate-npm-package-licensewcwidthvaryvm2walkerupdate-browserslist-dbuniversal-user-agentweb-streams-polyfillwebidl-conversionswhatwg-urlwhich-builtin-typewhichwhich-boxed-primitivewhatwg-fetchwildcard-matchuntildifyword-wrapwhich-typed-arraywindows-releasewrite-file-atomicwrappywhich-collectionwrap-ansiwordwrapwsxdg-basedirwidest-linextendy18nwhich-moduleyargs-parseryallistyargswrap-ansi-cjsynyocto-queueyaml
0.1.2

6 months ago

0.1.1

6 months ago

0.1.0

6 months ago