さあみなさん、買わなくていいのでちょっと見ていってください。
本日ご紹介する商品は、こちらの日めくりカレンダーです。
どうですこのボディー。レシートプリンターそっくりでしょう?
実はカレンダーを毎朝6時30分に印刷する優れものなんです!
もちろん時刻はお好みに合わせて変更することができます。
カレンダーをめくるのに失敗してがっかりしたことありますよね?
この商品があれば再印刷できるので何度でもやり直しができます!
しかも印刷時にピヨピヨと鳴るメーカーオプションの大音量ブザー付き!
音量は調節できるので、目覚まし時計としてもお使いいただけます!
これだけではありません!今回は特別に Node.js のソースコードもお付けします!
LAN 対応のローカル版、さらに CloudPRNT 対応のクラウド版をご用意いたしました。
ローカル版
local.js
constnet=require('net');constcron=require('node-cron');constreceiptline=require('receiptline');const{convert}=require('convert-svg-to-png');cron.schedule('0 30 6 * * *',()=>{// ReceiptLineconsttext=`\n\n\n\n\n\n\n\n
\`"^^^~~~~~~~2021年~~~~~~~
^令和3年
April|^^^^"4月|卯月
"^^^^^^^1
^^^木曜日
Thursday
-
\エイプリルフール/
{b:line}
|"2021年 3月|"2021年 4月|
-
|_日 月 火 水 木 金 土|_日 月 火 水 木 金 土|
|~~ 1 2 3 4 5 6|~~ ~~ ~~ ~~ 1 2 3|
|\`7\`8 9 10 11 12 13|\`4\`5 6 7 8 9 10|
|\`14\` 15 16 17 18 19 \`20\`|\`11\` 12 13 14 15 16 17|
|\`21\` 22 23 24 25 26 27|\`18\` 19 20 21 22 23 24|
|\`28\` 29 30 31 ~~ ~~ ~~|\`25\` 26 27 28 \`29\` 30 ~~|
{b:space}`;// SVGconstsvg=receiptline.transform(text,{encoding:'cp932'});// PNGconvert(svg).then(png=>{// Printerconstprinter={host:'192.168.1.253',port:9100,gamma:1.0,upsideDown:true,cutting:false,command:'starmbcs'};constsocket=net.connect(printer.port,printer.host,()=>{socket.end(receiptline.transform(`{x:\x07}\n|{i:${png.toString('base64')}}`,printer),'binary');});socket.on('error',err=>{console.log(err.message);});});});
クラウド版
cloud.js
constexpress=require('express');constapp=express();constcron=require('node-cron');constreceiptline=require('receiptline');const{convert}=require('convert-svg-to-png');// ReceiptLinelettext='';cron.schedule('0 30 6 * * *',()=>{// ReceiptLinetext=`\n\n\n\n\n\n\n\n
\`"^^^~~~~~~~2021年~~~~~~~
^令和3年
April|^^^^"4月|卯月
"^^^^^^^1
^^^木曜日
Thursday
-
\エイプリルフール/
{b:line}
|"2021年 3月|"2021年 4月|
-
|_日 月 火 水 木 金 土|_日 月 火 水 木 金 土|
|~~ 1 2 3 4 5 6|~~ ~~ ~~ ~~ 1 2 3|
|\`7\`8 9 10 11 12 13|\`4\`5 6 7 8 9 10|
|\`14\` 15 16 17 18 19 \`20\`|\`11\` 12 13 14 15 16 17|
|\`21\` 22 23 24 25 26 27|\`18\` 19 20 21 22 23 24|
|\`28\` 29 30 31 ~~ ~~ ~~|\`25\` 26 27 28 \`29\` 30 ~~|
{b:space}`;});// Serverapp.post('/calendar',(req,res)=>{// Print Jobif(text.length>0){res.json({jobReady:true,mediaTypes:['application/vnd.star.starprnt']});}else{res.json({jobReady:false});}})app.get('/calendar',(req,res)=>{// SVGconstsvg=receiptline.transform(text,{encoding:'cp932'});// PNGconvert(svg).then(png=>{// Printerconstprinter={gamma:1.0,upsideDown:true,cutting:false,command:'starmbcs'};// Commandconstcommand=Buffer.from(receiptline.transform(`{x:\x07}\n|{i:${png.toString('base64')}}`,printer),'binary');res.status(200).type('application/vnd.star.starprnt').send(command);text='';});});app.listen(8080,()=>{console.log('Server running at http://localhost:8080/');});
さらにさらに!日めくりカレンダーのデザインをカスタマイズできるツールも無料でご提供!
https://receiptline.github.io/designer/
ReceiptLine
`"^^^~~~~~~~2021年~~~~~~~
^令和3年
April|^^^^"4月|卯月
"^^^^^^^1
^^^木曜日
Thursday
-
\エイプリルフール/
{b:line}
|"2021年 3月|"2021年 4月|
-
|_日 月 火 水 木 金 土|_日 月 火 水 木 金 土|
|~~ 1 2 3 4 5 6|~~ ~~ ~~ ~~ 1 2 3|
|`7` 8 9 10 11 12 13|`4` 5 6 7 8 9 10|
|`14` 15 16 17 18 19 `20`|`11` 12 13 14 15 16 17|
|`21` 22 23 24 25 26 27|`18` 19 20 21 22 23 24|
|`28` 29 30 31 ~~ ~~ ~~|`25` 26 27 28 `29` 30 ~~|
{b:space}
どうですみなさん、すごいでしょう?
・・・エイプリルフールネタにしてみました。
マークダウン言語で紙のレシートや電子レシートを簡単に作れる receiptline。
パッケージに添付されているプログラム例を参考に作りました。
https://github.com/receiptline/receiptline
receiptline で SVG に変換後、さらにプリンターコマンドに変換しています。
4月1日固定なので、当日の日付を印刷するように修正してくださいね!
また何か作ったら投稿します。ではまた!