Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9101f7f877 | |||
| a34ee8c3fd | |||
| a29cb74f39 | |||
| 16bbac62fc | |||
| b835ac45d7 | |||
| a6cc742fa0 | |||
| c8d679d6a9 | |||
| 7da3b16077 |
18
README.md
18
README.md
@ -1,21 +1,19 @@
|
||||
# ITS Thermal Printer
|
||||
|
||||
Local client-only tool, will generate a PDF for the client to print as needed.
|
||||
|
||||
Grab the latest version (`ITThermal vX.Y.Z.zip`) from the [Releases section](https://git.vfsh.dev/helpd_admin/it-thermal/releases).
|
||||
Grab the latest version (`ITThermal vX.Y.Z.zip`) from the [Releases section](https://git.vfsh.dev/sgrant/mccs-thermal/releases).
|
||||
|
||||
## Usage
|
||||
|
||||
# Usage
|
||||
1. Extract the `ITThermal.zip` file to a local directory
|
||||
2. Open `index.html` in a modern web browser (Chrome, Firefox, Edge, etc.)
|
||||
3. Fill out one of the available forms and click "Generate Receipt"
|
||||
4. A PDF of the receipt will be generated and displayed on the page
|
||||
5. If you're using FireFox the print dialog will open automatically. For other browsers, use the print functionality of your browser's PDF viewer.
|
||||
#### Important Note: The scaling must be set to **100%** or **Actual Size** to ensure proper formatting on the thermal printer. FireFox should do this automatically, but other browsers (namely Edge and Chrome) will default to "Fit to Page" which will mess up the formatting and print approximately 500 miles of white space before the receipt.
|
||||
|
||||
# Notes
|
||||
- Uses jsPDF library for PDF generation:
|
||||
- https://rawgit.com/MrRio/jsPDF/master/docs/jsPDF.html
|
||||
### Important Note: The scaling must be set to **100%** or **Actual Size** to ensure proper formatting on the thermal printer. FireFox should do this automatically, but other browsers (namely Edge and Chrome) will default to "Fit to Page" which will mess up the formatting and print approximately 500 miles of white space before the receipt
|
||||
|
||||
# To Do
|
||||
- Add error handling on the front end for missing/invalid fields
|
||||
- Make notes on DT actually optional
|
||||
- Add a class for better font handling
|
||||
## Notes
|
||||
|
||||
- Uses [jsPDF](https://rawgit.com/MrRio/jsPDF/master/docs/jsPDF.html) library for PDF generation
|
||||
|
||||
110
src/assets/Classes.js
Normal file
110
src/assets/Classes.js
Normal file
@ -0,0 +1,110 @@
|
||||
/**
|
||||
* Represents a line item with text, font information, and spacing options.
|
||||
* @param {String} text The contents of the line
|
||||
* @param {FontInfo} fontInfo Font details to use for the line
|
||||
* @param {Boolean} moveDownAfter Provide extra spacing after this line?
|
||||
* @returns LineItem
|
||||
*/
|
||||
class LineItem {
|
||||
constructor(text, fontInfo, moveDownAfter) {
|
||||
this.text = text;
|
||||
this.fontInfo = fontInfo;
|
||||
this.moveDownAfter = moveDownAfter || false;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the contents of the line
|
||||
* @param {String} text The contents of the line
|
||||
* @returns LineItem
|
||||
*/
|
||||
setText(text) {
|
||||
if (typeof text !== 'string') {
|
||||
throw new Error('Text must be a string');
|
||||
}
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font information for the line
|
||||
* @param {FontInfo} fontInfo Font details to use for the line
|
||||
* @returns LineItem
|
||||
*/
|
||||
setFontInfo(fontInfo) {
|
||||
if (!(fontInfo instanceof FontInfo)) {
|
||||
throw new Error('fontInfo must be an instance of FontInfo');
|
||||
}
|
||||
this.fontInfo = fontInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether to provide extra spacing after this line
|
||||
* @param {Boolean} moveDownAfter Provide extra spacing after this line?
|
||||
* @returns LineItem
|
||||
*/
|
||||
setMoveDownAfter(moveDownAfter) {
|
||||
if (typeof moveDownAfter !== 'boolean') {
|
||||
throw new Error('moveDownAfter must be a boolean');
|
||||
}
|
||||
this.moveDownAfter = moveDownAfter;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents font information including name, size, and style.
|
||||
* @param {String} name The font name
|
||||
* @param {Number} size The font size
|
||||
* @param {String} style The font style
|
||||
* @returns FontInfo
|
||||
*/
|
||||
class FontInfo {
|
||||
constructor(name, size, style) {
|
||||
this.name = name || 'Helvetica';
|
||||
this.style = style || '';
|
||||
this.size = size || 12;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font name
|
||||
* @param {String} name The font name
|
||||
* @returns FontInfo
|
||||
*/
|
||||
setName(name) {
|
||||
if (typeof name !== 'string') {
|
||||
throw new Error('Font name must be a string');
|
||||
}
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font size
|
||||
* @param {Number} size The font size
|
||||
* @returns FontInfo
|
||||
*/
|
||||
setSize(size) {
|
||||
if (typeof size !== 'number' || size <= 0) {
|
||||
throw new Error('Font size must be a positive number');
|
||||
}
|
||||
this.size = size;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font style
|
||||
* @param {String} style The font style
|
||||
* @returns FontInfo
|
||||
*/
|
||||
setStyle(style) {
|
||||
if (typeof style !== 'string') {
|
||||
throw new Error('Font style must be a string');
|
||||
}
|
||||
this.style = style;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@ -157,6 +157,7 @@
|
||||
</div>
|
||||
<!-- Script Calls -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js" integrity="sha384-NaWTHo/8YCBYJ59830LTz/P4aQZK1sS0SneOgAvhsIl3zBu8r9RevNg5lHCHAuQ/" crossorigin="anonymous"></script>
|
||||
<script src="./assets/Classes.js"></script>
|
||||
<script src="./assets/ITThermal.js"></script>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
</body>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user