#1 Re: PDF Engine » Add image to a page in a parallel task » 2023-08-04 08:55:14

Do you means something like this?
Or there is a Gdip.Lock already available?
Sorry, I never used GDI+ before.

          try
            for I := 0 to FSelectedFiles.Count - 1 do
            begin
              LFileName := FSelectedFiles[I];
              LPicture.LoadFromFile(LFileName);

              LPDFPage := LPDFDocument.AddPage;
              LPDFDocument.CreateBookMark(0, 'Page ' + IntToStr(I));
              LPDFDocument.CreateOutline('Page ' + IntToStr(I), 0, 0);

              CritialSection.Acquire

              try
                LPDFImage := TPdfImage.Create(LPDFDocument, LPicture, True);
                LPDFDocument.AddXObject('Page' + IntToStr(I), LPDFImage);
                LPDFDocument.Canvas.DrawXObject(0,0, LPDFPage.PageWidth, LPDFPage.PageHeight, 'Page' + IntToStr(I));
              finally
                CriticalSection.Release;
              end;
            end;

            LPDFDocument.SaveToFile(FDestinationFileName);

#2 PDF Engine » Add image to a page in a parallel task » 2023-08-03 13:03:46

mrsw
Replies: 2

Hi,
I am developing an application for convertion of a bounce of image files in pdf files, each image must represent a pdf page.

The code I wrote is:

          LPDFDocument := TPDFDocument.Create(True, 0, pdfa2A);
          LPDFDocument.DefaultPageLandscape := False;
          LPDFDocument.DefaultPaperSize := psA3;
          LPDFDocument.Info.Title := 'Simple PDF document';
          LPDFDocument.Info.CreationDate := Now;
          LPDFDocument.Info.Creator := 'My PDF converter app';

          LPicture := TSynPicture.Create;

          try
            for I := 0 to FSelectedFiles.Count - 1 do
            begin
              LFileName := FSelectedFiles[I];
              LPicture.LoadFromFile(LFileName);

              LPDFPage := LPDFDocument.AddPage;
              LPDFDocument.CreateBookMark(0, 'Page ' + IntToStr(I));
              LPDFDocument.CreateOutline('Page ' + IntToStr(I), 0, 0);
              LPDFImage := TPdfImage.Create(LPDFDocument, LPicture, True);
              LPDFDocument.AddXObject('Page' + IntToStr(I), LPDFImage);
              LPDFDocument.Canvas.DrawXObject(0,0, LPDFPage.PageWidth, LPDFPage.PageHeight, 'Page' + IntToStr(I));
            end;

            LPDFDocument.SaveToFile(FDestinationFileName);

If this code is execute in the main thread of the application it works perfectly, if executed in a parallel task it hang to DrawXObject line.
All the objects are created in the executing task.
If I comment AddXObject and DrawXObject lines the code works and the result is a PDF file with blank pages.

Where I'm wrong?
How can I make the code thread safe?

I can send a sample app reproducing the problem.

I'm using Delphi version 11.2 and mORMot2 from GitHub.

Thanks.

#3 Re: mORMot 1 » Firebird and Dialect 3 quoted field names » 2019-09-13 15:28:13

I also noticed on the same Sample project, after applyed quoted field names option on the server side, an error (field not found) is raised when on the client side is made a search of a previously inserted message.
Field names are not quoted on building the sql statement!

#4 Re: mORMot 1 » Firebird and Dialect 3 quoted field names » 2019-09-13 14:37:32

ab wrote:

Those dialects are quite a mess...

I tried to implement rpmQuoteFieldName new mapping option, which does the MapField() call for all fields.
See https://synopse.info/fossil/info/582c350655
Feedback is welcome! Especially I am not sure if it works fully with the ID field...

Thanks ab,
I'll try it.

In the mean time I do other tests with the framework: new problem! The first time the server is started and CreateMissingTables is called, all goes fine, the table is created, but next time the server starts it tries to update the table adding an index that already exists. Why? Where I'm wrong?

#5 Re: mORMot 1 » Firebird and Dialect 3 quoted field names » 2019-09-06 16:15:47

I managed to get around the problem mapping the time field to "Time".
Tabe was successfully created.
This is the code

Model.Props[TSQLSampleRecord].ExternalDB.MapField('Time', '"Time"');

Is this the only available way to do this or I can define a flag in the framework to tell it to quote field names?
Thanks.

  Carlo

#6 mORMot 1 » Firebird and Dialect 3 quoted field names » 2019-09-06 13:41:30

mrsw
Replies: 4

Hi,
I'm evaluating the mORMot framework for a new project of mine.
I use firebird as database server for many years and I would use it with the mORMot framework, but I encountered a problem. I ever used dialect 3 on firebird and double quoted field names.
I adapted the 04 - HTTP Client-Server sample to access a firebird database but CreateMissingTables fails because the field named Time is in conflict with firebird time field type. I don't find a place where instruct the framework to produce sql statements with field names enclosed in double quotes.
How could it be achieved?
Thanks in advance

Carlo

Board footer

Powered by FluxBB