Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
esc_pos_print_plus
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dio Maulana
esc_pos_print_plus
Commits
5103fdfe
Commit
5103fdfe
authored
Jul 18, 2019
by
Andrey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed columns alignment bug
parent
7b12f4dd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
7 deletions
+35
-7
CHANGELOG.md
CHANGELOG.md
+3
-0
printer.dart
lib/src/printer.dart
+31
-6
pubspec.yaml
pubspec.yaml
+1
-1
No files found.
CHANGELOG.md
View file @
5103fdfe
## [1.1.0]
*
Fixed columns alignment bug
## [1.1.0]
*
Added code page support
...
...
lib/src/printer.dart
View file @
5103fdfe
...
...
@@ -55,6 +55,10 @@ class Printer {
}
}
double
_colIndToPosition
(
int
colInd
)
{
return
colInd
==
0
?
0
:
(
512
*
colInd
/
11
-
1
);
}
/// Generic print for internal use
///
/// [colInd] range: 0..11
...
...
@@ -64,18 +68,34 @@ class Printer {
int
colInd
=
0
,
int
linesAfter
=
0
,
bool
cancelKanji
=
true
,
int
colWidth
=
12
,
})
{
final
int
pos
=
colInd
==
0
?
0
:
(
512
*
colInd
/
11
-
1
).
round
();
final
hexStr
=
pos
.
toRadixString
(
16
).
padLeft
(
3
,
'0'
);
const
charLen
=
11.625
;
// 48 symbols per line
double
fromPos
=
_colIndToPosition
(
colInd
);
// Align
if
(
colWidth
==
12
)
{
_socket
.
write
(
styles
.
align
==
PosTextAlign
.
left
?
cAlignLeft
:
(
styles
.
align
==
PosTextAlign
.
center
?
cAlignCenter
:
cAlignRight
));
}
else
{
final
double
toPos
=
_colIndToPosition
(
colInd
+
colWidth
)
-
11
;
final
double
textLen
=
text
.
length
*
charLen
;
if
(
styles
.
align
==
PosTextAlign
.
right
)
{
fromPos
=
toPos
-
textLen
;
}
else
if
(
styles
.
align
==
PosTextAlign
.
center
)
{
fromPos
=
fromPos
+
(
toPos
-
fromPos
)
/
2
-
textLen
/
2
;
}
}
final
hexStr
=
fromPos
.
round
().
toRadixString
(
16
).
padLeft
(
3
,
'0'
);
final
hexPair
=
HEX
.
decode
(
hexStr
);
_socket
.
write
(
styles
.
bold
?
cBoldOn
:
cBoldOff
);
_socket
.
write
(
styles
.
turn90
?
cTurn90On
:
cTurn90Off
);
_socket
.
write
(
styles
.
reverse
?
cReverseOn
:
cReverseOff
);
_socket
.
write
(
styles
.
underline
?
cUnderline1dot
:
cUnderlineOff
);
_socket
.
write
(
styles
.
align
==
PosTextAlign
.
left
?
cAlignLeft
:
(
styles
.
align
==
PosTextAlign
.
center
?
cAlignCenter
:
cAlignRight
));
_socket
.
write
(
styles
.
fontType
==
PosFontType
.
fontA
?
cFontA
:
cFontB
);
// Text size
_socket
.
add
(
...
...
@@ -177,7 +197,12 @@ class Printer {
for
(
int
i
=
0
;
i
<
cols
.
length
;
++
i
)
{
final
colInd
=
cols
.
sublist
(
0
,
i
).
fold
(
0
,
(
int
sum
,
col
)
=>
sum
+
col
.
width
);
_print
(
cols
[
i
].
text
,
styles:
cols
[
i
].
styles
,
colInd:
colInd
);
_print
(
cols
[
i
].
text
,
styles:
cols
[
i
].
styles
,
colInd:
colInd
,
colWidth:
cols
[
i
].
width
,
);
}
_socket
.
writeln
();
...
...
pubspec.yaml
View file @
5103fdfe
name
:
esc_pos_printer
description
:
The library allows to print receipts using a ESC/POS (usually thermal) network printer. It can be used in Flutter or Dart projects. In Flutter, both Android and iOS are supported.
version
:
1.1.
0
version
:
1.1.
1
author
:
Andrey Ushakov <flutter@tablemi.com>
homepage
:
https://github.com/andrey-ushakov/esc_pos_printer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment