Method Signatures
- void RequestToPrint(List<
OutputText
> outputTexts) - Task<
NexoRequestResult
> RequestToPrintAsync(List<OutputText
> outputTexts)
Description
This method is typically used for printing the sale receipt for an integrated A920pro terminal. The method may only be called before or after a PaymentRequest has been sent to the terminal, which means it may be sent after a GetPaymentInstrument, but not during the actual payment which in general starts when the amount is known.
Some formatting is possible regarding font size and alignment. An OutputText generates a line break. It is however possible to have one OutputText spanning several lines by using a 0x0A for line break in the Content member.
OutputText Class
OutputText class used when calling RequestToPrint to use the A920pro printer.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
namespace SwpTrmLib.Nexo {
public class OutputText
{
public enum CharacterHeights { Normal, SingleHeight, DoubleHeight, HalfHeight };
public enum CharacterWidths { Normal, SingleWidth, DoubleWidth };
public enum Alignments { Left, Right, Centred, Justified };
public enum Colors { Black, White};
public CharacterHeights Height { get; set; } = CharacterHeights.Normal;
public CharacterWidths Width { get; set; } = CharacterWidths.Normal;
public Alignments Alignment { get; set; } = Alignments.Left;
public Colors Color { get; set; } = Colors.Black;
public int StartRow { get; set; } = 0;
public string Content { get; set; } = string.Empty;
public XElement XML();
}
}
Printing on A920Pro
Example using RequestToPrint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Prerequisites: PAX is an instace of ISwpTrmImp_1 using an A920pro.
// Login has been made.
using SwpTrmLib.Nexo;
void MyTestOfA920proPrinter()
{
List<OutputText> textToPrint = new List<OutputText>();
textToPrint.Add(new OutputText() {
Content = "Text using default style"
});
textToPrint.Add(new OutputText() {
Content = "Larger text",
Height = CharacterHeights.DoubleHeight,
Width = CharacterWidth.DoubleWidht,
Alignment = Alignments.Centred
});
// StartRow is paper feed in pixels
textToPrint.Add(new OutputText() {
StartRow = 200,
Content = "Space before this text",
Alignment = Alignments.Right
});
// Text divided left and right using tab and alignment
textToPrint.Add(new OutputText() {
Content = "Left\tRight",
Alignment = Alignments.Justified
});
textToPrint.Add(new OutputText() {
Content = "This text is\x0a divided on several\x0a lines with the\x0a same formatting",
Alignment = Alignments.Justified
});
PAX.RequestToPrint(textToPrint);
}
Printing Payment Result
Example printing sale receipt on A920Pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
NexoPaymentResult r = await PAX.Payment(amount);
if (string(IsNullOrEmpty(r.ReceiptBlobNoHeader)) {
// Create list for recipt print on A920Pro
List<OutputText> items = new List<OutputText>();
// Add normal sale receipt
AddSaleReceiptHeaderAndItems(items);
// Add terminal receipt
items.Add(new OutputText() {
Content = "Card payment:"
});
items.Add(new OutputText()
{
Content = r.ReceiptBlobNoHeader,
StartRow = 40,
});
AddFooter(items);
_ = await PAX.RequestToPrint(items);
}
}