Translating strings on the fly

alnotasalnotas Greece
edited 8:40PM in FastReport VCL 5
Hello from Greece!

I'm trying to achieve automatic translation of each Greek word that is printed on the report to English.
I'm using the PreviewPages property of the report, right after the report has been prepared and scan through all the MemoView objects and changing it's text;
...
   MainReport.Prepare;
   DoTranlsateReport;
   MainReport.ShowPreparedReport;
...

procedure DoTranslateReport;
var
   p, o : integer;
   fAllObjects: TList;
   oView : TfrxMemoView;
begin
   for p:=0 to MainReport.PreviewPages.Count-1 do
   begin
      for o:=0 to MainReport.PreviewPages.Page[p].AllObjects.Count-1 do
      begin
         fAllObjects := MainReport.PreviewPages.Page[p].AllObjects;
         if TfrxComponent(fAllObjects.Items[o]) is TfrxMemoView then
         begin
            oView := TfrxMemoView(TfrxComponent(fAllObjects.Items[o]));
            oView.Text := EngTranslate(oView.Text);
         end;
      end;
   end;
end;

This seems to work on the preview, tranlating every static text and every field value but the problem starts when I hit print and starting to print.
The preview page flickers and all the pages' text is automatically returned to Greek and it's Greek that is printed on the paper.
It's seems the original Greek pages are being cached during preparing and are used to return to the original state after hitting 'Print'.

I tried changing some properties like
MainReport.EngineOptions.UseFileCache := true / false
MainReport.PreviewOptions.PagesInCache := 0..100
but nothing seems to work.

How can I change the RESULTED PAGES of the prepared report and print the translated result?

Comments

  • alnotasalnotas Greece
    edited 8:40PM
    Updated from 5.3.16 to 5.5.2
    ...
    Nothing changed....

    Any clues? Anybody?
  • gpigpi
    edited 8:40PM
    Use MainReport.PreviewPages.ModifyPage(p, o); to apply changes
  • alnotasalnotas Greece
    edited 8:40PM
    gpi wrote: »
    Use MainReport.PreviewPages.ModifyPage(p, o); to apply changes

    Thank you so, SOOOO much!
    It worked!

    >

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.