删除了问题的原始描述 -
" 打印机输出到纸张是缩略图大小 " - 问题解决了。
导致问题的原因:
"打印机的分辨率高于您的屏幕,例如对于96ppi和600ppi,你将拥有约1/6的图像尺寸" - 在StackOverFlow上发布。
原始代码:
procedure TForm1.PrintClick(Sender: TObject);
begin
if PrintDialog1.Execute then
begin
with Printer do
begin
BeginDoc;
Panel1.PaintTo(Canvas, 0,0); //prints contents of Panel1 only
Form1.PaintTo(Canvas, 0, 600); //screenshot/cast of Window
EndDoc;
end;
end;
end;
已解决的代码:
需要将内容复制到剪贴板并从剪贴板中打印:
procedure TForm1.Button6Click(Sender: TObject);
var
MyRect: TRect;
scale: Double;
R: TRect;
Bitmap: TBitmap;
begin
if PrintDialog1.Execute then
begin
Bitmap := TBitmap.Create;
try
//copy content of Panel1 to Clipboard:
R := Rect(0, 0, Panel1.Width, Panel1.Height);
Bitmap.SetSize(Panel1.Width, Panel1.Height);
Bitmap.Canvas.CopyRect(R, Panel1.Canvas, R);
//print content of Clipboard:
Printer.BeginDoc;
{scale := Printer.PageWidth / Bitmap.Width; //large print
scale := (Printer.PageWidth / (Bitmap.Width / 2)); //twice the size of large print
scale := ((Printer.PageWidth/2) / Bitmap.Width); //reduce size}
scale := Printer.PageWidth / Bitmap.Width; //print full page
ShowMessage(FloatToStr(scale)); // '30', '17.5', '8.75'
{ horizontal pixels, vertical pixels, bit depth 600 x 600 x 24}
MyRect.Left := 0;
MyRect.Top := 0;
MyRect.Right := trunc(Bitmap.Width * scale);
MyRect.Bottom := trunc(Bitmap.Height * scale);
Printer.Canvas.StretchDraw(MyRect, Bitmap);
Printer.EndDoc;
finally
bitmap.free;
end;
end;
end;
答案 0 :(得分:0)
解决:
需要将内容复制到剪贴板并从那里打印 - 现在代码放大并打印或多或少我想要的尺寸:D **代码' Frankensteined'来自网络