问题还是得自己解决。
发布答案并散分,谢谢大家的热心帮助!
function ScanStream(T :TStream; S :string):Integer;
var
i,j:Integer;
p
char;
lSize:Int64;
begin
T.Position := 0;
lSize := T.Size;
Result := 0;
GetMem(p,lSize);
T.ReadBuffer(p^,lSize);
for i := 0 to lSize -1 do
begin
for j:=1 to Length(S) do
if p[i+j]<>S[j] then Break;
if j>length(S) then
begin
Result:=i+1;
Break;
end;
end;
FreeMem(p);
end;
procedure UnpachPDFOleStreamToFile(T :TStream; AFileName :string);
var
lOutStream :TMemoryStream;
lStart,lEnd,lPDFSize : Integer;
lStartStr,lEndStr : String;
begin
lStartStr := '%PDF';
lStart := ScanStream(T,lStartStr);
lEndStr := '%%EOF';
lEnd := T.Size;
lPDFSize := lEnd - lStart;
if lPDFSize > 0 Then
begin
lOutStream := TMemoryStream.Create;
T.Seek(lStart,soFromBeginning);
lOutStream.CopyFrom(T,Int64(lPDFSize));
lOutStream.SaveToFile(AFileName);
lOutStream.Free;
end;
end;