delphi 里如何实现打印报表自适应纸张的功能
解决方案 »
- 麻烦问一下, delphi.net现在是不是不存在了?
- 请问scrollbar来控制控件移动的问题!
- 問一個菜鳥問題:窗體居中為何總是會偏下
- 应朋友之请写的《基于MCVC方式进行分布式系统开发》,请大家指教!
- 求助:delphi+sqlsever2000,数据库问题!!!急
- TADOTable主从表中从表的Locate问题。
- 大家有无EPSON的打印控制代码 ESC/P-K 参考手册?
- Delphi的ActiveXForm制作半透明窗体的问题,高手请进。
- 提问我想在ClientDataSet中用filter进行模糊查询应该怎么写呢???????
- 是英雄就来.......
- 请问query,adoquery 和table ,adotable对字段的是分别怎么操作的
- 如何取得当前默认打印机上自定义纸张的大小?
在执行打印前调用以下函数:
procedure SetPaperSize(X, Y: Integer);
// 单位是0.1mm
// A4时 Printer.Pagewidth:=1440; A5时 Printer.Pagewidth:=1049;
// B5时 Printer.Pagewidth:=1290; 16K时 Printer.Pagewidth:=1035;
// lq1600宽行打印机这个值宽度最大为42cm左右, 长度大约2m。
//改变devicemode结构
var
Device: array[0..255] of char;
Driver: array[0..255] of char;
Port: array[0..255] of char;
hDMode: THandle;
PDMode: PDEVMODE;
begin
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then
begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then
begin
if (x = 0) or (y = 0) then
begin
{Set to legal}
pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
{pDMode^.dmPaperSize := DMPAPER_LEGAL; changed by wulianmin}
pDMode^.dmPaperSize := DMPAPER_FANFOLD_US;
end
else
begin
{Set to custom size}
pDMode^.dmFields := pDMode^.dmFields or
DM_PAPERSIZE or
DM_PAPERWIDTH or
DM_PAPERLENGTH;
pDMode^.dmPaperSize := DMPAPER_USER;
pDMode^.dmPaperWidth := x {SomeValueInTenthsOfAMillimeter};
pDMode^.dmPaperLength := y {SomeValueInTenthsOfAMillimeter};
end;
{设定纸张来源}
pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
pDMode^.dmDefaultSource := DMBIN_MANUAL;
GlobalUnlock(hDMode);
end;
end;
Printer.PrinterIndex := Printer.PrinterIndex;
//以下开始打印
Printer.BeginDoc;
Printer.Canvas.TextOut(100,100, 'Test 1');
Printer.EndDoc;
end;