API PrinCube
Hello! Our organization wants to use your printer in its program. Is it possible to print text from our program without creating a project? For example: print ("My text"). Or maybe you can write text to the label in the finished project and send the project to print?
You can use any tool to convert the text to a png image, then use the headless conversion method of the dev document to convert the png image to a dedicated mbd file, and then use the curl command or other methods to upload mdb to the printer.
Text to png example: (ImageMagick command tool)
$ convert -background white -fill black -pointsize 84 -font Helvetica label:'My text' out.png
Convert data and upload the data to printer: (ref: https://github.com/dukelec/mb/blob/master/doc/dev.md#headless-conversion)
# under js/workers/mbc/ :
./mbc-node.js out.png 0.mbd
curl -F "[email protected]" http://192.168.44.1/cgi-bin/upload
OK. We want to use it on Android OS. You will need to install NodeJS with the application?
In my opinion, if you want to perform some automated printing and content changes, you should write an app yourself. You can choose which platform to run your app on.
You can edit a project first, export it, and modify the text in the project externally. The project format is the general msgpack format. However, the modified mbp project still needs to generate a special data format mbd through some apps before it can be transmitted to the printer.
If you want to implement your own app on the android platform, my suggestion is to modify this app, and also use web browser or webview to run the conversion function, refer to: https://github.com/dukelec/mb/blob/master/doc/dev.md#data-convert
If android has root privileges, I personally like to create a standard linux image file, after mounting it, chroot in, install nodejs and other tools in standard linux through the built-in package manager, and then you can perform data conversion through the command line, and you can Generate an external interface through busybox httpd for external calls.
Of course, the simpler approach is to use linux directly instead of android.
Thank. I will try to write my own function for converting png to mbd similar to mbc-node.js. Need the same in C++ for Windows.
_
However, the modified mbp project still needs to generate a special data format mbd through some apps before it can be transmitted to the printer
_
Can you comment in detail?
App work: mbp -> png -> mbd. You can ignore mbp -> png, only png -> mbd.
Can you please provide a sample use of /cgi-bin/cmd (for rm_upload, e.g.)? Also, can you commend on how the headless convertor mbc-node.js resizes *.png? I've got it working fine most of the time (convert | mbc_node | /cgi-bin/upload route) - for example, I made some kind of numerator to print 36 page numbers. However some of PNGs got folded upon themselves, and can't figure out what was the difference. Do you have "native" height of the image in pixels? - I would rather have all the sizing done at the preprocessing stage.
@palagraph Usage of rm_upload: Before upload ".mbd" files to printer, you should remove old files first by simply access: http://192.168.44.1/cgi-bin/cmd?cmd=rm_upload
The "native" height of the image in pixels is 684.
convert -background white -fill black -pointsize 84 -font Helvetica label:'My text' out.png
./mbc-node.js out.png 0.mbd
curl -F "[email protected]" http://192.168.44.1/cgi-bin/upload
works, but is slow. In another thread you talked about conversion taking much time due to aliasing etc. Es there any documentation of the .mbd file format?
I also tried heights 600,1200 and 684 but conversion still is very slow.
convert -background white -fill black -pointsize 84 -font Helvetica label:'My text' out.png ./mbc-node.js out.png 0.mbd curl -F "[email protected]" http://192.168.44.1/cgi-bin/uploadworks, but is slow. In another thread you talked about conversion taking much time due to aliasing etc. Es there any documentation of the .mbd file format?
I also tried heights 600,1200 and 684 but conversion still is very slow.
Hi, I've uploaded the C version of the conversion tool and most of the conversion work is done by imagemagick's convert command.
If you want to increase the speed further, you need to reduce the size of the picture in the middle of the process, or implement your own faster dither tool.
The .mbd file format can be found in the c source code.
@dukelec I cloned the project https://github.com/dukelec/mbrush and cd to mb_ser/js/workers/mbc but could not find the file mbc-node.js so that I can use it to convert .png file to .mbd. Could you please confirm if I need to use any other file to convert png to mbd file?
I tried to use the command ./mbc-head-node.js 3.png 0.mbd to convert the file but got the following error:
dyld[56321]: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.73.dylib
Referenced from: <AE727B67-9775-3527-B45E-268760857C4A> /usr/local/Cellar/node/20.3.1/bin/node
Reason: tried: '/usr/local/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/usr/local/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/usr/local/lib/libicui18n.73.dylib' (no such file), '/usr/lib/libicui18n.73.dylib' (no such file, not in dyld cache), '/usr/local/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file), '/usr/local/Cellar/icu4c/74.2/lib/libicui18n.73.dylib' (no such file), '/usr/local/lib/libicui18n.73.dylib' (no such file), '/usr/lib/libicui18n.73.dylib' (no such file, not in dyld cache)
[1] 56321 abort ./mbc-head-node.js 3.png 0.mbd
I want to use the api to upload the mdb file to printer and any help would be highly appreciated.
@dukelec @MarcWeber I upgraded npm using command brew upgrade npm and the above error ie, dyld[56321]: Library not loaded: went away.
Now I want to convert .png file to .mbd but I cannot find the file mbc-node.js in "master" branch of mbrush repository. Could you please confirm where I can find mbc-node.js file to convert .png to .mbd file instead?
I tried to convert it using v4 branch of this repository and used the following command and it displayed convert message convert out.png to 0.mbd but didn't create a 0.mbd file:
./mbc-head-node.js out.png 0.mbd
I'd really appreciate your help regarding how to convert png to mbd format.