Este otra versión de la función, interesante pero también presenta error:
Código Delphi
[-]
procedure TfrmPrincipal.ViewPDFInWebBrowser(WebBrowser: TWebBrowser; const Base64Str: string);
var
PDFBase64: TBase64Encoding;
PDFDoc: Variant;
HTMLString: WideString;
Stream: TStringStream;
begin
PDFBase64 := TBase64Encoding.Create;
try
PDFBase64.Decode(Base64Str);
PDFDoc := '' +
'<_embed width="100%" height="100%" type="application/pdf" ' +
'src="data:application/pdf;base64,' + Base64Str + '">' +
'';
HTMLString := PDFDoc;
Stream := TStringStream.Create(HTMLString, TEncoding.UTF8);
try
WebBrowser.Navigate('about:blank');
while WebBrowser.ReadyState < READYSTATE_INTERACTIVE do
Application.ProcessMessages;
(WebBrowser.Document as IPersistStreamInit).Load(TStreamAdapter.Create(Stream));
finally
Stream.Free;
end;
finally
PDFBase64.Free;
end;
end;