Fortes Reports

https://delphiprogrammingdiary.blogspot.com/2018/06/fortes-report.html

https://fortes4lazarus.sourceforge.net/tutorials/basic_1.html

https://fortes4lazarus.sourceforge.net/tutorials/basic_2.html

uses
RLReport, RLPrinters, Printers;

procedure ConfigureReportForThermalPrinter(Report: TRLReport);
begin
// Set paper type to custom
Report.PageSetup.PaperSize := fpCustom;

// Set custom paper width and height
// Note: Height is set to 0 for continuous paper
Report.PageSetup.PaperWidth := 80; // 80mm width
Report.PageSetup.PaperHeight := 0; // Continuous paper

// Remove margins
Report.Margins.LeftMargin := 0;
Report.Margins.TopMargin := 0;
Report.Margins.RightMargin := 0;
Report.Margins.BottomMargin := 0;

// Set to use the entire paper width
Report.PrintDialog := False;
Report.Width := Report.PageSetup.PaperWidth * 3.78; // Convert mm to pixels (approximate)

// Disable page footer (usually not needed for receipts)
if Report.PageFooter.Enabled then
Report.PageFooter.Enabled := False;

// Set font to a common monospace font
Report.Font.Name := ‘Courier New’;
Report.Font.Size := 8;
end;

procedure PrintToThermalPrinter(Report: TRLReport; PrinterName: string);
var
PrinterIndex: Integer;
begin
// Find the index of the specified printer
PrinterIndex := Printer.Printers.IndexOf(PrinterName);

if PrinterIndex >= 0 then
begin
// Set the printer
Printer.PrinterIndex := PrinterIndex;

// Configure the report
ConfigureReportForThermalPrinter(Report);

// Print without showing dialog
Report.PrintDialog := False;
Report.Print;

end
else
ShowMessage(‘Printer not found: ‘ + PrinterName);
end;

Deja un comentario