
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
ng-thermal-print
Advanced tools
A library for connecting Angular apps with thermal printers.
WEBUSB API (No drivers needed. Only works with Chrome and Opera with USB connection)
WebPRNT (http)
ESC/POS
StarPRNT
Star WebPRNT
Install library
npm install ng-thermal-print
Import into your application
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { ThermalPrintModule } from 'ng-thermal-print'; //add this line
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
ThermalPrintModule //add this line
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.ts
import { PrintService, UsbDriver, WebPrintDriver } from 'ng-thermal-print';
import { Component } from '@angular/core';
import { PrintDriver } from 'ng-thermal-print/lib/drivers/PrintDriver';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
status: boolean = false;
usbPrintDriver: UsbDriver;
webPrintDriver: WebPrintDriver;
ip: string = '';
constructor(private printService: PrintService) {
this.usbPrintDriver = new UsbDriver();
this.printService.isConnected.subscribe(result => {
this.status = result;
if (result) {
console.log('Connected to printer!!!');
} else {
console.log('Not connected to printer.');
}
});
}
requestUsb() {
this.usbPrintDriver.requestUsb().subscribe(result => {
this.printService.setDriver(this.usbPrintDriver, 'ESC/POS');
});
}
connectToWebPrint() {
this.webPrintDriver = new WebPrintDriver(this.ip);
this.printService.setDriver(this.webPrintDriver, 'WebPRNT');
}
print(driver: PrintDriver) {
this.printService.init()
.setBold(true)
.writeLine('Hello World!')
.setBold(false)
.feed(4)
.cut('full')
.flush();
}
}
app.component.html
<strong>Status: {{status}}</strong>
<div>
<input [(ngModel)]="ip" type="text" name="ip" placeholder="IP of printer with WebPRNT">
<button (click)="connectToWebPrint()">Connect to WebPRNT</button>
</div>
<div>
<button (click)="requestUsb()">Connect to USB</button>
</div>
<div>
<button (click)="print()" [disabled]="status === false"> Print!</button>
</div>
FAQs
An angular module to add thermal printing capabilities.
The npm package ng-thermal-print receives a total of 122 weekly downloads. As such, ng-thermal-print popularity was classified as not popular.
We found that ng-thermal-print demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.