Home Devices
New Blog Posts: Merging Reports - Part 1 and Part 2

TExtraDevices: problem with clientdataset and TPDFDevice

edited July 2004 in Devices
Hi,

I have a websnap ISAPI dll which produces a (very basic) PDF report. I
stream the pdf to the webclient. The data comes from a clientdataset that
gets its data from an XML-file. The first time the PDF is generated,
everything is ok. The second time the dll hangs on this line of code:

rrptRap.PrintToDevices;

Full code:

// assign data file to xmlprovider
XMLProv.XMLDataFile := sTijd;
// close and open the clientdataset
cdsMaster.Close;
cdsMaster.Open;

// create the report and stream it back
with rrptRap do
begin
MS := TMemoryStream.Create;
HD := TPDFDevice.Create(nil);
try
HD.PrintToStream := True;
HD.ReportStream := MS;
HD.Publisher := rrptRap.Publisher;
rrptRap.PrintToDevices;
Response.ContentType := HD.ContentType;
Response.CustomHeaders.Add('Content-Disposition: inline; filename=xxx'
+
FormatDateTime('hddmmyyyyhhnn', Now) + '.pdf');
Response.CustomHeaders.Add('Accept-Ranges: bytes');
Response.SetCustomHeader('Cache-Control', '');
Response.ContentStream := MS;
Response.ContentStream.Position := 0;
Handled := True;
finally
FreeAndNil(HD);
end;
end;

This doesn't happen when the devicetype is Html.
Any idea what the problem is?

Thanks,

Bart Callewaert
This discussion has been closed.