Problem with ppArchiveReader and ppViewer - Version 14
Hi
I was using without problems (version 12) a form with a ppArchiveRader, a
ppviewer, a DBGrid and a query.
The code is:
procedure TFSLE1Reimprimedoc.Q1AfterScroll(DataSet: TDataSet);
begin
try
TBlobfield(Q1.FieldByname( 'RPRaf' )).SaveToFile(
'C:\SLE\TempPrint.RAF' );
ppArchiveReader1.ArchiveFileName := 'C:\SLE\TempPrint.RAF' ;
ppArchiveReader1.PrintToDevices;
ppArchiveReader1.Reset;
except
end;
end;
It could not be the most elegant way to view the cocuments, but everything
works beautifully.
After compile with version 14, when I open the query it shows the docunment
of the first record.
If you scroll the grid, it apears a error message: Cannot create file
"C:\SLE\TempPrint.Raf. The file is beeing used by anotyher process"
and the view do not change from the first document.
if someone could help: What has to be changed ?
thank you
Edison Garcia
I was using without problems (version 12) a form with a ppArchiveRader, a
ppviewer, a DBGrid and a query.
The code is:
procedure TFSLE1Reimprimedoc.Q1AfterScroll(DataSet: TDataSet);
begin
try
TBlobfield(Q1.FieldByname( 'RPRaf' )).SaveToFile(
'C:\SLE\TempPrint.RAF' );
ppArchiveReader1.ArchiveFileName := 'C:\SLE\TempPrint.RAF' ;
ppArchiveReader1.PrintToDevices;
ppArchiveReader1.Reset;
except
end;
end;
It could not be the most elegant way to view the cocuments, but everything
works beautifully.
After compile with version 14, when I open the query it shows the docunment
of the first record.
If you scroll the grid, it apears a error message: Cannot create file
"C:\SLE\TempPrint.Raf. The file is beeing used by anotyher process"
and the view do not change from the first document.
if someone could help: What has to be changed ?
thank you
Edison Garcia
This discussion has been closed.
Comments
Edison
Try resetting the ArchiveReader before saving the archive to file. Then
new scrollable viewer will generate the report in a background thread so
it will hold onto the file longer than before. Calling reset after
PrintToDevice is likely not actually closing the file.
try
ppArchiveReader1.Reset;
//create file...
ppArchiveReader1.ArchiveFileName := ...;
ppArchiveReader1.PrintToDevices;
...
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I was using the Reset after the Print (since it works in the first pass -
preparing for the 2nd pass)
TBlobfield(Q1.FieldByname( 'RPRaf' )).SaveToFile(
'C:\SLE\TempPrint.RAF' );
ppArchiveReader1.ArchiveFileName := 'C:\SLE\TempPrint.RAF' ;
ppArchiveReader1.PrintToDevices;
ppArchiveReader1.Reset;
and it is working. I found that the problem was when I try to show the
..TempPrint.Raf in a ppviewer. I suppose that the viewer was in some way
locking the disc file.
so, when I scroll the database, the first record was shown in the viewer and
the second, generate an error when the ArchiveReader tried to record the
new file.
The strange is that this routine works for several years untill we migrate
to version 14.
to keep it functioning I had create 2 different procedures, one to print
(in printer) and another to show in the viewer (using a ppDBArchiveReader),
what is not the best solution, but it is working.
Now I have:
procedure TFSLE1Reimprimedoc.Q1AfterScroll(DataSet: TDataSet);
begin { to show int the viewer }
try
ppViewer1.Reset;
ppDBArchiveReader1.DatabaseSettings.Name :=
Q1.FieldByName('RPKey').AsString;
ppDBArchiveReader1.PrintToDevices;
ppViewer1.Refresh;
Sleep(100);
except
ShowMessage('Por favor aguarde!');
end;
end;
procedure TFSLE1Reimprimedoc.SpeedButton1Click(Sender: TObject);
begin { paper }
TBlobfield(Q1.FieldByname( 'RPRaf' )).SaveToFile(
'C:\SLE\TempPrint.RAF' );
ppArchiveReader1.ArchiveFileName := 'C:\SLE\TempPrint.RAF' ;
ppArchiveReader1.Print;
ppArchiveReader1.Reset;
end;
as I said, it?s working. I could not solve the problem using only a
ppDBArchiveReader,! I suppose it would work better since I would not record
any file at disk.
There are some way?
Thanks
Edison
To enable advanced features such as page scrolling and multiple page
viewing, the viewer needed to be completely redesigned.
As I mentioned in my previous post, the report pages are now generated
in a background thread. This means that even though you are making a
call to ArchiveReader.Reset, the viewer is likely not yet done
generating pages and the command is ignored. Resetting the device
before printing is a better place to perform this action altogether.
If you would like to revert back to the way RB 12 worked, you can set
the TppViewer.SinglePageOnly property to True and your old code should
function correctly.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
thank you for uyour answer.
I will try to do it.
Best Regards,
Edison