TMSFMXGrid printed different from what is visible

Hi, I have few problems with printing my grids, one is that it looks different from what I see in grid and from what comes out of printer.
here is what it is on the screen
PrintScreen_CompTest.pdf (28.2 KB)

and what I get after printing it
Test_Detail.pdf (676.9 KB)

What code are you using exactly? How are you printing? Are you sending the PDF to the printer or are you using a different way for printing?

this is one of the output : see attachment

Regardless of printer, neither works, I am getting same results. I set up printer and then I call grid.print()CurrentPck.txt (4.0 KB)

Hi,

What exactly are you using for printing? The code attached is only showing grid initialization but nothing for printing?

var str:string;
begin
sg_pck_report.Options.Printing.DPI:=Point(600, 600);
str:=eb_pck_Student_ID.Text + 'pck' + e_pck_Package_ID.Text ;

sg_pck_report.Print();

I was also setting Description and Title, page number but it won't show as well.

what class is sg_pck_report exactly?

it is just the name I am using for my TMSFMXGrid. I have two grids on the form, in one I see acctual lessons
and in secong sg_pck_report I combine data from student and package information, that is why I need merge cells and then data from other grid in table like view.

Can you perhaps use the TTMSFMXGridPDFIO component to export to PDF and then print the PDF instead. The Print method exports to an image, and doesn't take quality into account.

Great, that works good. One last question : How do I get rid of cell border, I have them set to none but in pdf they are there.

Can you please let me know how to get rid of cell borders in TTMSFMXGridPDFIO, I have them set to non in TMSFMXGrid but they still shows in TTMSFMXGridPDFIO.

Can you try setting TMSFMXGridPDFIO1.Options.CellLayout to gclNone and override the OnGetCellLayout during export:

TMSFMXGrid1.BeginUpdate;
FExporting := True;
TMSFMXGridPDFIO1.Save(Fn);
FExporting := False;
TMSFMXGrid1.EndUpdate;

procedure TForm1.TMSFMXGrid1GetCellLayout(Sender: TObject; ACol, ARow: Integer;
  ALayout: TTMSFMXGridCellLayout; ACellState: TCellState);
begin
  if FExporting then
  begin
    ALayout.StrokeDash := TStrokeDash.Custom;
    ALayout.Stroke.Kind := TBrushKind.None;
    ALayout.Sides := [];
  end;
end;

Great, that works, thank you very much.

1 Like

Can you help\me\to get rid of margins? In both TMSFMXGrid and TMSFMXGridPDFIO I set up heather size to 0 as well as margins, but in actual pdf I still have what looks like either empty heather or margin app 1inch.

This code can be used to clear all margins, footer and header settings

TMSFMXGrid1.BeginUpdate;
  FExporting := True;
  TMSFMXGridPDFIO1.Options.Header := '';
  TMSFMXGridPDFIO1.Options.Footer := '';
  TMSFMXGridPDFIO1.Options.HeaderSize := 0;
  TMSFMXGridPDFIO1.Options.FooterSize := 0;
  TMSFMXGridPDFIO1.Options.Margins.Left := 0;
  TMSFMXGridPDFIO1.Options.Margins.Top := 0;
  TMSFMXGridPDFIO1.Options.Margins.Right := 0;
  TMSFMXGridPDFIO1.Options.Margins.Bottom := 0;
  TMSFMXGridPDFIO1.Save('test.pdf');
  FExporting := False;
  TMSFMXGrid1.EndUpdate;