我做了一个小程序,你输入了一堆东西,它把它放到一个富编辑中,但是现在我如何打印富编辑的内容呢?
我在想RichEdit1.print();,但我不知道把什么放在括号里。富编辑有6个不同的页边距(每个项目有2个(名称、数量和价格))
如果有人愿意帮忙,我会非常感激的!
发布于 2014-03-06 19:54:23
传递一个参数,即包含打印作业名称的字符串。如果要相信文档,则此名称将出现在打印管理器中:
使用“打印”打印富编辑控件的内容。标题参数指定打印管理器和网络标题页中出现的标题。
您还需要在打印之前设置PageRect。这定义了打印机上的页面尺寸。您需要查询所选打印机的设备功能,并应用任何边距。我用这个助手函数来完成这个任务:
procedure PrintRichEdit(RichEdit: TRichEdit; const Caption: string;
const PrinterMargin: Integer);
//the units of TRichEdit.PageRect are pixels, units of PrinterMargin are mm
var
PrinterHeight, PrinterWidth: Integer;
LogPixels, PrinterTopLeft: TPoint;
PageRect: TRect;
Handle: HDC;
begin
Handle := Printer.Handle;
LogPixels := Point(GetDeviceCaps(Handle, LOGPIXELSX),
GetDeviceCaps(Handle, LOGPIXELSY));
PrinterTopLeft := Point(GetDeviceCaps(Handle, PHYSICALOFFSETX),
GetDeviceCaps(Handle, PHYSICALOFFSETY));
PrinterWidth := Printer.PageWidth;
PrinterHeight := Printer.PageHeight;
PageRect.Left := Max(0, Round(PrinterMargin*LogPixels.X/25.4)
- PrinterTopLeft.X);
PageRect.Top := Max(0, Round(PrinterMargin*LogPixels.Y/25.4)
- PrinterTopLeft.Y);
PageRect.Right := PrinterWidth-PageRect.Left;
PageRect.Bottom := PrinterHeight-PageRect.Top;
if (PageRect.Left>=PageRect.Right) or (PageRect.Top>=PageRect.Bottom) then
//the margins are too big
PageRect := Rect(0, 0, 0, 0);
RichEdit.PageRect := PageRect;
RichEdit.Print(Caption);
end;https://stackoverflow.com/questions/22234371
复制相似问题