Web PDFDownload from xData Stream

I'm trying to use application.PDFDownload using a service implementation with xData sending binary stream from blog storing PDF
similar to function Get_PDFFile : TStream;
Postman test is OK (I retrieve PDF) but I get difficulties to convert
TXDataClientResponse from RawInvokeASync to use it as
AData: TBytes;
const AData: TJSUint8Array;

Is there an example about such conversion ?

Yes, there is a full demo showing all the ins and outs of using binary and text blobs with XData and TMS Web Core. It's in folder <xdata>\demos\web\blob.

HI Wagner
I saw this demo, it was very useful about integration of blob inside web core app
(and I discovered yesterday evening the new release with usage of addEventListener )

But here I would like to use PDFDownload in order to display a PDF in a new tab
These can be done from TBytes or TJSUint8Array
And as the response from my xdata service is a TStream I have to convert content to one of them.
Demo contains example to go from Base64 to TStream (as TJSArrayBuffer or TJSUInt16Array)
Here I'm trying to convert from TStream to right format

procedure TApplicationHelper.DownloadPDFFile(const AData: TBytes; const AFileName: string; const ANewTab: Boolean);
procedure TApplicationHelper.DownloadPDFFile(const AData: TJSUint8Array; const AFileName: string; const ANewTab: Boolean);

I will avoid to use application.Navigate as access to PDF doc should be protected

Do you get an example about right transcode format please?


Hi Wagner

Finally I found and it was quite simple only by casting

ResponseSync := RawInvokeASync...
PDFJS        := TJSUInt8Array(ResponseSync.Result);

Thanks again to TMS team for such magic tools !

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.