Record Class PrinterProfile
- Record Components:
charsPerLine- number of Font A columns on one line (at least 8)codePage- ESC t code page number sent at the start of each receipt (0 = PC437 on Epson-compatible printers), 0..255charset- Java charset matchingcodePage, used to turn text into bytesreplacements- text substitutions applied before encoding, for characters the printer's code page does not have; copied, never null afterwards
The TVS RP 3200 Lite prints 72 mm at 203 DPI = 576 dots. With the default Font A (12 dots wide) that is 48 characters on 80 mm paper and 32 characters on 58 mm paper. Use the constants for those two cases:
PrinterProfile.RP3200_80MM // 48 chars, PC437, Rupee sign -> "Rs."
PrinterProfile.RP3200_58MM // 32 chars
PrinterProfile.RP3200_80MM.withReplacement("₹", "INR ") // customise
Profiles are immutable and thread-safe; the with... methods return new profiles.
Any other ESC/POS printer works too - create a profile with its line width.
Character set
Text is sent in the printer's code page (PC437 by default, which covers ASCII plus
Western European accents and box-drawing characters). Before encoding, the
replacements() are applied - by default the Rupee sign becomes "Rs.",
curly quotes become straight quotes, dashes become - and the ellipsis becomes
.... Anything still unprintable becomes ?. Indian scripts (Tamil,
Devanagari, ...) cannot be printed as text by this printer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PrinterProfileTVS RP 3200 Lite with 58 mm paper: 32 characters per line, code page PC437, default replacements.static final PrinterProfileTVS RP 3200 Lite with 80 mm paper: 48 characters per line, code page PC437, default replacements. -
Constructor Summary
ConstructorsConstructorDescriptionPrinterProfile(int charsPerLine, int codePage, Charset charset, Map<String, String> replacements) Creates a profile. -
Method Summary
Modifier and TypeMethodDescriptioncharset()Returns the value of thecharsetrecord component.intReturns the value of thecharsPerLinerecord component.intcodePage()Returns the value of thecodePagerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thereplacementsrecord component.final StringtoString()Returns a string representation of this record class.withCharsPerLine(int chars) Returns a copy with a different line width, e.g. 64 when the printer is set to the smaller Font B.withCodePage(int page, Charset cs) Returns a copy that uses another code page.withReplacement(String from, String to) Returns a copy with one extra (or overridden) text replacement, e.g.
-
Field Details
-
RP3200_80MM
TVS RP 3200 Lite with 80 mm paper: 48 characters per line, code page PC437, default replacements. This is the default used byReceiptTemplate.render(Object). -
RP3200_58MM
TVS RP 3200 Lite with 58 mm paper: 32 characters per line, code page PC437, default replacements.
-
-
Constructor Details
-
PrinterProfile
public PrinterProfile(int charsPerLine, int codePage, Charset charset, Map<String, String> replacements) Creates a profile. Prefer the constants andwith...methods for normal use.- Parameters:
charsPerLine- number of Font A columns on one linecodePage- ESC t code page number, 0..255charset- Java charset matchingcodePagereplacements- substitutions applied before encoding; may be null (none)- Throws:
IllegalArgumentException- ifcharsPerLine < 8orcodePageis out of rangeNullPointerException- ifcharsetis null
-
-
Method Details
-
withCharsPerLine
Returns a copy with a different line width, e.g. 64 when the printer is set to the smaller Font B.- Parameters:
chars- characters per line, at least 8- Returns:
- the new profile
-
withCodePage
Returns a copy that uses another code page. The printer's code page number and the Java charset must describe the same table, e.g.withCodePage(19, Charset.forName("IBM858"))for PC858 (PC437 plus the Euro sign) on Epson-compatible printers. Check the printer's self-test page for the numbers it supports.- Parameters:
page- the ESC t code page number, 0..255cs- the matching Java charset- Returns:
- the new profile
-
withReplacement
Returns a copy with one extra (or overridden) text replacement, e.g.withReplacement("₹", "INR ")to print the Rupee sign as"INR ".- Parameters:
from- the text to replaceto- what to print instead- Returns:
- the new profile
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
charsPerLine
public int charsPerLine()Returns the value of thecharsPerLinerecord component.- Returns:
- the value of the
charsPerLinerecord component
-
codePage
public int codePage()Returns the value of thecodePagerecord component.- Returns:
- the value of the
codePagerecord component
-
charset
Returns the value of thecharsetrecord component.- Returns:
- the value of the
charsetrecord component
-
replacements
Returns the value of thereplacementsrecord component.- Returns:
- the value of the
replacementsrecord component
-