画布打印的问题,应该很多人都遇到过,请赐教,谢谢!

WangZWang 2006-06-07 05:18:09
var
DMode: PDevMode;
h: THandle;
Device, Drive, Port: PChar;
OldLeft: Integer;
begin
with Printer do
begin
Device := StrAlloc(255);
Drive := StrAlloc(255);
Port := StrAlloc(255);
GetPrinter(Device, Drive, Port, h);
DMode := LocalLock(h);
DMode.dmPaperSize := 256;
DMode.dmPaperLength := 2100;
DMode.dmPaperWidth := 2000;
LocalUnLock(h);
SetPrinter(Device, Drive, Port, h);
StrDispose(Device);
StrDispose(Drive);
StrDispose(Port);

BeginDoc;
OldLeft := MainPanel.Left;
MainPanel.Left := 1500;
try
MainPanel.ScaleBy(200, 100);
MainPanel.PaintTo(Handle, 30, 10);
MainPanel.ScaleBy(100, 200);
finally
MainPanel.Left := OldLeft;
end;
EndDoc;
end;
.................
end;
{ 以上代码实现Panel中打印,用针式打印机可以打印正常,但用喷墨,激光打印机
打印出来的内容就非常小,不是针式打印机打印出来的实际尺寸,请赐教,谢谢! }
...全文
284 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
WangZWang 2006-06-09
  • 打赏
  • 举报
回复
问题已经解决,产生原因有下面产生
MainPanel.ScaleBy(200*natio, 100*natio);
MainPanel.PaintTo(Handle, 30*natio, 10*natio);
MainPanel.ScaleBy(100*natio, 200*natio);
改为
MainPanel.ScaleBy(100*natio, 100);
MainPanel.PaintTo(Handle, 30*natio, 10*natio);
MainPanel.ScaleBy(100 , 100*natio);
WangZWang 2006-06-08
  • 打赏
  • 举报
回复
var
DMode: PDevMode;
h: THandle;
Device, Drive, Port: PChar;
OldLeft, pcdpi,prdpi,natio: Integer;
begin
with Printer do
begin
//------------------------------这段代码是不是在喷墨打印机上打有问题?
Device := StrAlloc(255);
Drive := StrAlloc(255);
Port := StrAlloc(255);
GetPrinter(Device, Drive, Port, h);
DMode := LocalLock(h);
DMode.dmPaperSize := 256;
DMode.dmPaperLength := 2100;
DMode.dmPaperWidth := 2000;
LocalUnLock(h);
SetPrinter(Device, Drive, Port, h);
StrDispose(Device);
StrDispose(Drive);
StrDispose(Port);
// -----------------------------------------------
BeginDoc;
//这里以x轴大小为例,还可以取得y的分辨率
{ --------------------------}
pcdpi:=getdevicecaps(getdc(0),LOGPIXELSX);
prdpi:=getdevicecaps(printer.handle,LOGPIXELSX);
natio:=round(prdpi/pcdpi);

OldLeft := MainPanel.Left *natio;
MainPanel.Left := 1500*natio;

try
MainPanel.ScaleBy(200*natio, 100*natio);
MainPanel.PaintTo(Handle, 30*natio, 10*natio);
MainPanel.ScaleBy(100*natio, 200*natio);
finally
MainPanel.Left := OldLeft*natio;
end;

EndDoc;
end;
end;


// 请高手提出一些建议呀,谢谢!
WangZWang 2006-06-08
  • 打赏
  • 举报
回复
绝对不是分辨率的问题,都一样。不要想其他原因。
就在同一台机子上,针式打印机打印的正常,而
喷墨打印机却非常的小,几乎看不见字体,请各位帮忙为谢。
zsr 2006-06-07
  • 打赏
  • 举报
回复
分辨率不一样,当然大小不一样。

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧