ESC/POS コマンドでそれを実現する方法が見つかりませんでした。だから、これはフォーマット機能の私の実現です:
procedure TNativePrint.DoAddLineWithTwoAlignments(const ALeftStr : string;
ALeftStrFont : TFontType;
ALeftStrFontStyle : TFontStyle;
const ARightStr : string;
ARightStrFont : TFontType;
ARightStrFontStyle : TFontStyle;
APrintAreaWidth : integer = 500);
const
vFomatLine = '';
var
vOffset : integer;
vCharSize : integer;
vLeftSize : integer;
vRightSize : integer;
begin
vCharSize := 12;
if (ALeftStrFont = ftFontA) then begin
vCharSize := 12;
end else if (ALeftStrFont = ftFontB) then begin
vCharSize := 9;
end;
if (ALeftStrFontStyle in [fsDoubleWidth, fsDoubleHW, fsBoldDoubleWidth, fsBoldDoubleHW]) then begin
vCharSize := vCharSize * 2;
end;
vLeftSize := length(ALeftStr) * vCharSize;
if (ARightStrFont = ftFontA) then begin
vCharSize := 12;
end else if (ARightStrFont = ftFontB) then begin
vCharSize := 9;
end;
if (ARightStrFontStyle in [fsDoubleWidth, fsDoubleHW, fsBoldDoubleWidth, fsBoldDoubleHW]) then begin
vCharSize := vCharSize * 2;
end;
vRightSize := length(ARightStr) * vCharSize;
vOffset := APrintAreaWidth - ( vLeftSize + vRightSize);
DoSetFont(ALeftStrFont, ALeftStrFontStyle);
DoAddLine(ALeftStr, false);
DoSetFont(ARightStrFont, ARightStrFontStyle);
DoAddLine(#$1B'\'+AnsiChar(vOffset)+#0, false);
DoAddLine(ARightStr);
end;
ご覧のとおり、フォント、フォントスタイル、印刷領域の幅を分析しています。それに基づいてオフセットを計算します