Hi,
I'm having some problems with printing my report.
I've been able to create a rather nice report (I'm proud if). When the report is shown in preview mode it looks fine and printing one report is no problem. I just wonder wy there are used 2 print dialogs. I mean, when you just hit "OK" then te report is printed immediately. But when you click "proportions" There is another similar looking dialog with a bit more options. It really goes wrong when i want more then one copy and want it to be sorted. No matter I select "sorted" ore not the output to the printer is NOT sorted. Fore example: I wont 3 copy's from a 2 page report, i get the order 1,1,1,2,2,2,3,3,3 instead of 1,2,3,1,2,3,1,2,3. I already tried to bypass the first dialog by not creating a preview but printed the report from code:
procedure TDataModule_Rapporten.print;
var
FromPage, ToPage, NumberCopies: Integer;
ind: Integer;
AppDirectory: String;
Collap: Boolean;
begin
// Load report definition from application directory
frReportPlanning.LoadFromFile('rapporten\Planning.lrf');
// Need to keep track of which printer was originally selected to check for user changes
ind:= Printer.PrinterIndex;
// Prepare the report and just stop if we hit an error as continuing makes no sense
if not frReportPlanning.PrepareReport then Exit;
// Set up dialog with some sensible defaults which user can change
with PrintDialog1 do
begin
Options:=[poPageNums]; // allows selecting pages/page numbers
Copies:=1;
Collate:=true; // ordened copies
FromPage:=1; // start page
ToPage:=frReportPlanning.EMFPages.Count; // last page
MaxPage:=frReportPlanning.EMFPages.Count; // maximum allowed number of pages
if Execute then // show dialog; if succesful, process user feedback
begin
if (Printer.PrinterIndex <> ind ) // verify if selected printer has changed
or frReportPlanning.CanRebuild // ... only makes sense if we can reformat the report
or frReportPlanning.ChangePrinter(ind, Printer.PrinterIndex) //... then change printer
then
frReportPlanning.PrepareReport //... and reformat for new printer
else
exit; // we couldn't honour the printer change
if PrintDialog1.PrintRange = prPageNums then // user made page range selection
begin
FromPage:=PrintDialog1.FromPage; // first page
ToPage:=PrintDialog1.ToPage; // last page
end;
NumberCopies:=PrintDialog1.Copies; // number of copies
collate:=PrintDialog1.Collate;
// Print the report using the supplied pages & copies
showmessage('test');
frReportPlanning.PrintPreparedReport(inttostr(FromPage)+'-'+inttostr(ToPage), NumberCopies);
end;
end;
end;
But without any difference in the printer output.
(This code I copied from
http://wiki.lazarus.freepascal.org/LazReport_Tutorial#Printing )
When my compiled program is running on windows server 2003 the problem is the same.
Printing and collating from other applications is no problem.
I'm Using Windows 7 as OS and my lazarus version is 1.2.2 (SVN 44758)
Any help would be appreciated.