initial upload
This commit is contained in:
parent
ac114da487
commit
7c1cfdff51
63 changed files with 6883 additions and 0 deletions
63
routes/api.generate.mjs
Normal file
63
routes/api.generate.mjs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
|
||||
import {
|
||||
Router
|
||||
} from "express";
|
||||
|
||||
import {
|
||||
Label,
|
||||
Grid,
|
||||
Text,
|
||||
Line,
|
||||
Box,
|
||||
Circle,
|
||||
Barcode,
|
||||
PrintDensity,
|
||||
Spacing
|
||||
} from "jszpl";
|
||||
|
||||
import {
|
||||
Printer as PrinterTable
|
||||
} from "../sequelize/printer.model.mjs";
|
||||
|
||||
import {
|
||||
Template as TemplateTable
|
||||
} from "../sequelize/template.model.mjs";
|
||||
|
||||
import {
|
||||
Medium as MediaTable
|
||||
} from "../sequelize/media.model.mjs";
|
||||
|
||||
import {
|
||||
Queue as QueueTable
|
||||
} from "../sequelize/queue.model.mjs";
|
||||
|
||||
|
||||
export var Routes = Router();
|
||||
|
||||
|
||||
Routes.post('/generate-zpl', async function (Request, Response)
|
||||
{
|
||||
const label = new Label();
|
||||
label.printDensity = new PrintDensity(8);
|
||||
label.width = 100;
|
||||
label.height = 50;
|
||||
label.padding = new Spacing(10);
|
||||
|
||||
const text = new Text();
|
||||
label.content.push(text);
|
||||
text.fontFamily = new FontFamily(FontFamilyName.D);
|
||||
text.text = 'Hello World!';
|
||||
|
||||
const zpl = label.generateZPL();
|
||||
|
||||
await PrinterTable.create({
|
||||
name: Request.body.name,
|
||||
socket_addr: Request.body.socket_addr,
|
||||
socket_port: Request.body.socket_port,
|
||||
density: Request.body.density,
|
||||
type: "zpl"
|
||||
});
|
||||
|
||||
Response.status(200);
|
||||
Response.end();
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue