delphi打印小票源码

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

//取得字符的高度function CharHeight:

Word;

var

Metrics:

TTextMetric;

begin

GetTextMetrics(Printer.Canvas.Handle, Metrics); Result :

= Metrics.tmHeight;

end;

//file:

//取得字符的平均宽度

function AvgCharWidth:

Word;

var

Metrics:

TTextMetric;

begin

GetTextMetrics(Printer.Canvas.Handle, Metrics); Result :

= Metrics.tmAveCharWidth;

end;

//file:

//取得纸张的物理尺寸---单位:点function GetPhicalPaper:

TPoint;

var

PageSize :

TPoint;

begin

//file:

//PageSize.X;纸张物理宽度-单位:点//file:

//PageSize.Y;纸张物理高度-单位:点Escape(Printer.Handle, GETPHYSPAGESIZE, 0,nil,@PageSize);

Result :

= PageSize;

end;

//file:

//2.取得纸张的逻辑宽度--可打印区域

//file:

//取得纸张的逻辑尺寸

function PaperLogicSize:

TPoint;

var

APoint:

TPoint;

begin

APoint.X :

= Printer.PageWidth;

APoint.Y :

= Printer.PageHeight;

Result :

= APoint;

end;

//file:

//纸张水平对垂直方向的纵横比例function HVLogincRatio: Extended;

var

AP:

TPoint;

begin

Ap :

= PaperLogicSize;

Result :

= Ap.y/Ap.X;

end;

//file:

//取得纸张的横向偏移量-单位:点function GetOffSetX: Integer;

begin

Result :

= GetDeviceCaps(Printer.Handle, PhysicalOffSetX);

end;

//file:

//取得纸张的纵向偏移量-单位:点function GetOffSetY: Integer;

begin

Result :

= GetDeviceCaps(Printer.Handle, PhysicalOffSetY);

end;

//file:

//毫米单位转换为英寸单位

function MmToInch(Length:

Extended):

Extended;

begin

Result :

= Length/25.4;

end;

//file:

//英寸单位转换为毫米单位

function InchToMm(Length:

Extended):

Extended;

begin

Result :

= Length*25.4;

end;

//file:

//取得水平方向每英寸打印机的点数function HPointsPerInch:

Integer;

begin

Result :

= GetDeviceCaps(Printer.Handle, LOGPIXELSX);

end;

//file:

//取得纵向方向每英寸打印机的光栅数function VPointsPerInch:

Integer;

begin

Result :

= GetDeviceCaps(Printer.Handle, LOGPIXELSY) end;

//file:

//横向点单位转换为毫米单位

function XPointToMm(Pos:

Integer):

Extended;

begin

Result :

= Pos*25.4/HPointsPerInch;

end;

//

//file:

//纵向点单位转换为毫米单位

function YPointToMm(Pos: Integer):

Extended;

begin

Result :

= Pos*25.4/VPointsPerInch; end;

//file:

//设置纸张高度-单位:

mm

procedure SetPaperHeight(Value: integer);

var

Device :

array[0..255] of char;

Driver :

array[0..255] of char;

Port :

array[0..255] of char; hDMode :

THandle;

相关文档
最新文档