#1 Re: PDF Engine » PDF:AddXObject is slow and out of memory! » 2023-10-15 13:14:13

I test with the TPdfDocumentGdi , and set the i from 1 to 70000,it out of memory!

var
  // PDF: TPdfDocument;
  PDF: TPdfDocumentGDI;
  PDFPage: TPdfpage;
  SW: TStopwatch;
  I: Integer;
  FS: TFileStream;
  pdfImage: TPdfImage;
  BarCode: string;
  X, Y: Single;
  aRect: TRect;
begin
  SW := TStopwatch.StartNew;
  PDF := TPdfDocumentGDI.Create;
  // PDF := TPdfDocument.Create;
  FS := TFileStream.Create(ExtractFilePath(Application.ExeName) + 'output.pdf', fmCreate);
  try
    PDF.NewDoc;
    PDF.PDFA1 := True;
    PDF.DefaultPaperSize := psA4;
    PDF.SaveToStreamDirectBegin(FS);
    aRect := Rect(Point(20, 40), Point(60, 80));
    for I := 1 to 70000 do
    begin
      PDF.AddPage;
      BarCode := IdGenerator.NextId.ToString;
      GDICommentJpegDirect(PDF.VCLCanvas.Handle, 'd:\test.jpg', aRect);
      PDF.SaveToStreamDirectPageFlush(True);
    end;
    PDF.SaveToStreamDirectEnd;
    Memo1.Lines.Add(SW.ElapsedMilliseconds.ToString);
  finally
    PDF.Free;
    FS.Free;
  end;

#2 PDF Engine » PDF:AddXObject is slow and out of memory! » 2023-10-15 03:40:48

Flashcqxg
Replies: 3

My code is as follows, the image test.jpg is only 5kb in size. The program ran for more than 10 minutes, but did not receive the expected PDF file. Finally, it indicated that there was insufficient memory.
How can I improve it? Thank you!

var
  PDF: TPdfDocument;
  PDFPage: TPdfpage;
  SW: TStopwatch;
  I: Integer;
  FS: TFileStream;
  pdfImage: TPdfImage;
  BarCode: string;
  X, Y: Single;
begin
  SW := TStopwatch.StartNew;
  PDF := TPdfDocument.Create;
  FS := TFileStream.Create(ExtractFilePath(Application.ExeName) + 'output.pdf', fmCreate);
  try
    PDF.NewDoc;
    PDF.PDFA1 := True;
    PDF.DefaultPaperSize := psA4;
    PDF.SaveToStreamDirectBegin(FS);

    for I := 1 to 30000 do
    begin
      PDF.AddPage;
      BarCode := IdGenerator.NextId.ToString;
      pdfImage := TPdfImage.CreateJpegDirect(PDF, 'd:\test.jpg', True);
      PDF.AddXObject(BarCode, pdfImage);
      X := 200;
      Y := 800;
      PDF.Canvas.DrawXObject(X, Y, 30, 30, BarCode);
      pdfImage.ForceSaveNow;
      PDF.SaveToStreamDirectPageFlush(True);
    end;
    PDF.SaveToStreamDirectEnd;
    Memo1.Lines.Add(SW.ElapsedMilliseconds.ToString);
  finally
    PDF.Free;
    FS.Free;
  end;

#4 PDF Engine » MultilineTextRect does not work correctly » 2023-06-26 14:10:14

Flashcqxg
Replies: 2

my code:
var
  PDF: TPdfDocument;
  R: TPdfRect;


      R.Left := 30;
      R.Top := 500;
      R.Right := 100;
      R.Bottom := 800;
      PDF.Canvas.SetFont('Times New Roman', 12, []);
      PDF.Canvas.MultilineTextRect(R, 'Welcome to mORMot Open Source', True);

Only the text 'Welcome to' is displayed, no other text is displayed.
Thanks.

#6 mORMot 1 » TSynDBDataSet:How to update data when there is an alias field ? » 2020-06-01 14:56:30

Flashcqxg
Replies: 2

My code:
var
  props: TSQLDBWinHTTPConnectionProperties;
  SQL: TStringBuilder;
begin
  props := TSQLDBWinHTTPConnectionProperties.Create('127.0.0.1', 'XXX', '123', '123');
  SQL := TStringBuilder.Create;
  DD := TSynDBDataSet.Create(self);
  DD.Connection := props;
  SQL.Append('SELECT XGSTUFSID,XM,').AppendLine;
  SQL.Append('CASE WHEN SUBSTRING(BKZYDM,3,1) IN(''5'',''6'') THEN ''2'' ELSE ''1'' END LX').AppendLine;
  SQL.Append('FROM BBK').AppendLine;
  DD.CommandText := SQL.ToString;
  DD.Open;

When I modify the field of XM,and call Post and ApplyUpdates(0),but no data was saved.
How can i do ?Thanks.

#7 Re: mORMot 1 » Hope to add the NativeDB driver support for Sybase SQL Anywhere » 2020-06-01 14:35:09

Hi:
EgonHugeist,Can you send a copy of the updated the Native ASA driver of zeos for V17 to me?My Email:51536348@qq.com.
Thanks!

EgonHugeist wrote:

Just a note from me: I've updated the Native ASA driver of zeos for V17. Also did i add a new driver with protocol name "asa_capi" for the recommended sybase api.

#8 Re: mORMot 1 » Hope to add the NativeDB driver support for Sybase SQL Anywhere » 2020-04-27 00:51:45

ab wrote:

Are you sure that the 40,000 records are actually fetched, and not only the first dozen, just enough to be displayed?
We don't use open cursors (which tend to put any DB server on its knees when too much cursors are opened at once), but fetch all records as JSON and close the statement ASAP.
If it is too big/slow, reduce the number of records fetched by using paging.

I am not convinced that NativeDB is faster than FireDAC or Zeos. Usually, Zeos is faster than anything else on Delphi.
For instance, ZDBC or our SynDB classes are like NativeDB in concept: it bypasses the DB.pas unit and TDataSet.
I still suppose you are not fetching all rows, just the first ones.


For SQL Anywhere 17, I believe NativeDB is the fastest, this can be verified by testing.

#9 Re: mORMot 1 » Hope to add the NativeDB driver support for Sybase SQL Anywhere » 2020-04-15 11:33:19

So,currently,NativeDB is the best solution to access SAP SQL Anywhere.

#10 Re: mORMot 1 » Hope to add the NativeDB driver support for Sybase SQL Anywhere » 2020-04-14 12:02:34

Zeos can connect to the database, but it prompts an error when querying and failed.
The NativeDB query statement is the same as FireDAC, and the total amount of data to be obtained in the end is similar to the following code:

query.sql.add ('select * from test');
query.open();
query.fecthall();//for firedac

memo.lines.add (query.recordcont.tostring);

#11 Re: mORMot 1 » Hope to add the NativeDB driver support for Sybase SQL Anywhere » 2020-04-14 11:36:01

"Slow" is relative, mainly because NativeDB is too fast. I have tested, access SQL Anywhere on local machine, take out 40,000 records, NativeDB only needs 6-11ms, and FireDAC needs 700-900ms. As the server side, this speed experience is very obvious. Therefore, I hope to increase the NativeDB driver, thanks.

#12 Re: mORMot 1 » Hope to add the NativeDB driver support for Sybase SQL Anywhere » 2020-04-14 00:39:23

mpv wrote:

You can try SynDBOleDB, SynDBODBC or SynDBZeos. Hope all of them can connect to Sybase.

Thank you,they are too slow.

#13 mORMot 1 » Hope to add the NativeDB driver support for Sybase SQL Anywhere » 2020-04-13 03:05:31

Flashcqxg
Replies: 14

Hello:
NativeDB is a special drive for Sybase SQL Anywhere and extremely fast,NativeDB see http://www.nativedb.com/.
I want to use it for TSQLDBServerHttpApi,although now using TSQLDBFireDACConnectionProperties can connect to Sybase SQL Anywhere, but it's speed is relatively slow, far less than NativeDB.
Hope to add the NativeDB driver support for Sybase SQL Anywhere.
Thank a lot!

#15 mORMot 1 » TSQLDBServerHttpApi And Session verification » 2020-04-09 03:58:55

Flashcqxg
Replies: 2

Hello:
I am a new user of mormot,and more interested in TSQLDBServerHttpApi.
I want to use redis as a session manager for TSQLDBServerHttpApi,clients that have not passed session authentication cannot access the TSQLDBServerHttpApi server,BUT:

1) How to combine this redis session manager with TSQLDBServerHttpApi?
2) How does the client carry the session to access TSQLDBServerHttpApi

Thanks!

#17 Re: mORMot 1 » TSQLDBFireDACConnectionProperties and SAP SQL Anywhere 17 » 2020-04-05 14:15:34

ab wrote:

It is not supported yet.

What is the closest SQL dialect?


It's Transact-SQL ,like MS SQL.
Hope to support it as soon as possible.
Thanks a lot!

#18 mORMot 1 » TSQLDBFireDACConnectionProperties and SAP SQL Anywhere 17 » 2020-04-05 10:51:49

Flashcqxg
Replies: 4

I wanted to connect to SAP SQL Anywhere 17 by TSQLDBFireDACConnectionProperties:

var
FD: TSQLDBFireDACConnectionProperties;


FD := TSQLDBFireDACConnectionProperties.Create('ASA?ENG=test', 'TEST',
    'dba', 'sql');

Error Message:
TSQLDBFireDACConnectionProperties.Create:unknown provider-available: OraMSSQLMSAccMySQLSQLiteIBPGDB2Infx.

How to connect to the SAP SQL Anywhere 17 by TSQLDBFireDACConnectionProperties?
Thanks.

Board footer

Powered by FluxBB