Hello
How can I change the default page margins when printing?
I am currently getting a large page header border which is causing my sheet to overflow onto two pages.
Thanks
Hello
Sorry for the delay answering, didn't got a notification for this post and found it now when I came to answer the other question.
i am using your sample print procedure, how and where in this procedure would i reduce the margins say by half an inch?
procedure TForm1.PrintReport1Click(Sender: TObject);
var
PageCount: integer;
FirstPage, LastPage: integer;
PrintRange: TXlsCellRange;
ReallyPrint: boolean;
i: integer;
begin
FirstPage:=1;
LastPage:=-1;
PrintRange.Left:=1;
PrintRange.Top:=1;
PrintRange.Right:=Data.MaxPrintableCol;
PrintRange.Bottom:=Data.MaxPrintableRow;
//Find the print area.
for i:= 1 to FlexCelImport.RangeCount do
begin
if (FlexCelImport.RangeName = InternalNameRange_Print_Area) and (FlexCelImport.RangeSheet = FlexCelImport.ActiveSheet) then
begin
PrintRange.Top := FlexCelImport.RangeR1;
PrintRange.Bottom := FlexCelImport.RangeR2;
PrintRange.Left := FlexCelImport.RangeC1;
PrintRange.Right := FlexCelImport.RangeC2;
break;
end;
end;
if FlxPreview=nil then FlxPreview:=TFPreview.Create(Self);
FlxPreview.FlexCelPreview1.FlexCelGrid:=Data;
if PrintDialog=nil then PrintDialog:=TPrintDialog.Create(Self);
PrintDialog.MinPage:=1;
PrintDialog.FromPage:=1;
Data.CalcNumberOfPrintingPages(PageCount);
PrintDialog.Options := [poPageNums, poSelection];
PrintDialog.MaxPage:=PageCount;
PrintDialog.ToPage:=PageCount;
if FlexCelImport.PrintOptions and fpo_Orientation=0 then Printer.Orientation:=poLandscape else Printer.Orientation:=poPortrait;
if PrintDialog.Execute then
begin
if PrintDialog.PrintRange=prPageNums then
begin
FirstPage:=PrintDialog.FromPage;
LastPage:=PrintDialog.ToPage;
end;
if PrintDialog.PrintRange=prSelection then
begin
PrintRange.Left:=Data.Selection.Left;
PrintRange.Top:=Data.Selection.Top;
PrintRange.Right:=Data.Selection.Right;
PrintRange.Bottom:=Data.Selection.Bottom;
end;
Printer.Title:=ExtractFileName(OpenDialog.FileName);
FlxPreview.FlexCelPreview1.Init(PrintRange, FirstPage, LastPage);
try
ReallyPrint:=FlxPreview.ShowModal=mrOk;
finally
FlxPreview.FlexCelPreview1.Done; //Not really necessary, just to free resources
end; //finally
if ReallyPrint then Data.Print(PrintRange, FirstPage, LastPage);
end;
end;
Thanks
Just define a variable inside this method: