EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Get PDF from POST cmd how to save it as PDF from the DATABUFFER?

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.
#29764
Posted: 06/12/2014 09:33:54
by Walter Schrabmair (Priority Standard support level)
Joined: 05/03/2013
Posts: 150

Dear Experts,
I could do a websearch in a catalog with the ElHTTPSCLient1 sucessfully.
I get an PDF in return after the success full ElHTTPSCLIENT1.POST command.
Moreover I could see the DATA in a MEMO Field in Delphi 7.
But if I save this Memo to a File and would like to open it in a PDF Viewer I get the error " File corrupt!".

Could you tell me how to handle the recieved data in the OnData Subroutine?
I have done this by:
Code
procedure TForm1.ElHttpsClient1Data(Sender: TObject; Buffer: Pointer;
   Size: Integer);
var S : {$ifndef SB_UNICODE_VCL}string{$else}AnsiString{$endif};
begin
   SetLength(S, Size);
   Move(Buffer^, S[1], Size);
   MMLog.Text := MMLog.Text + S;
   if stage = 2 then
       MMPDF1.Text := MMPDF1.Text + S;
   if stage = 3 then
       MMPDF2.Text := MMPDF2.Text + S;


   Application.ProcessMessages;
end;

Thanks a lot.

ANd the next question is: How to save this PDF in a blob MySQL DB-Field (MyDAC)
Maybe it is important that the DATA I get from POST is UTF-8 encoded.
Can this be done with Delphi 7 ?
Walter
#29765
Posted: 06/12/2014 09:43:29
by Eugene Mayevski (EldoS Corp.)

Instead of using OnData event you need to create an instance of some stream and assign it to OutputStream property of TElHTTPSClient. You can create an instance of TMemoryStream (and then copy the data to the blob) or, if your method to access the DB offers some kind of TDBStream, use that one.


Sincerely yours
Eugene Mayevski
#29766
Posted: 06/12/2014 09:50:42
by Walter Schrabmair (Priority Standard support level)
Joined: 05/03/2013
Posts: 150

could you provide me with a simple example? Thanks
#29767
Posted: 06/12/2014 09:53:52
by Eugene Mayevski (EldoS Corp.)

Code
HTTPClient.OutputStream := TMemoryStream.Create;


Sincerely yours
Eugene Mayevski
#29768
Posted: 06/12/2014 10:05:49
by Walter Schrabmair (Priority Standard support level)
Joined: 05/03/2013
Posts: 150

Thanks, I never worked with streams before. Sorry.
How can I save this to a PDF FIle?
Thanks a lot.
#29769
Posted: 06/12/2014 10:15:03
by Walter Schrabmair (Priority Standard support level)
Joined: 05/03/2013
Posts: 150

I got it:

Code
  if SaveDialog1.Execute then
        begin
        MyStream2.SaveToFile(SaveDialog1.FileName);
        end;

      if SaveDialog2.Execute then
        begin
        MyStream3.SaveToFile(SaveDialog1.FileName);
        end;
Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.

Reply

Statistics

Topic viewed 415 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!