Here is a sample code:
Code: Select all
ms := TMemoryStream.Create();
ms.LoadFromFile('C:\temp\test.pdf');
DociStream := TStreamAdapter.Create(ms,soOwned);
GdPicturePDF1 := CreateComObject(CLASS_GdPicturePDF) as _GdPicturePDF;
if GdPicturePDF1.LoadFromIStream(DocIStream) = 0 then begin
GDPicturePDF1.CloseDocument;
end;
GdPicturePDF1 := nil;
DociStream := nil; // nothing happened here
TMemoryStream + TStreamAdapter
TMemoryStream should be released with TStreamAdapter but it seems TStreamAdapter isnt released. Any ideas why?
Edit - this works fine:
Code: Select all
ms := TMemoryStream.Create();
ms.LoadFromFile('C:\temp\test.pdf');
DociStream := TStreamAdapter.Create(ms,soOwned);
// no gdpicture here
DociStream := nil;