Page 1 of 1

Using TeePreviewPanel.Print and AsBitmap

Posted: Wed Apr 02, 2014 2:09 pm
by 16458388
Hello,
In my Chart tool I am using a customized print dialog which uses the TeePreviewPanel component for chart preview and print action. The tool uses Tee Chart Pro VCL 2013 for RAD Studio 2010 (Delphi). Now, our customers complained about the effect, that when printing the chart diagram the printed chart picture is not at all similar to the preview image of the panel or to the original chart window. Especially fonts and the legend box are printed too large compared to the chart dimensions.

So I tried to use the option AsBitmap before printing:

Code: Select all

   TeePreviewPanel.AsBitmap:=True;
   TeePreviewPanel.Refresh; 
   TeePreviewPanel.Print;
In most cases the print result is acceptable. However, in general the print out is a little bit coarse, and in one special case the printer produces just an empty (blank) page, when the option AsBitmap is active. If I switch this option off, this printer prints the chart (but with the wrong layout as described above). This printer is a "SHARP MX-2610N PCL6" laser printer.

Do you have any idea or alternative how to get better print results or how to fix this problem?
Best regards,
Andreas

Re: Using TeePreviewPanel.Print and AsBitmap

Posted: Thu Apr 03, 2014 10:55 am
by yeray
Hi Andreas,

I'd suggest you to take a look at the following resources:

- Printing Better article
- StretchDraw technique
- Printing Charts FAQ

Re: Using TeePreviewPanel.Print and AsBitmap

Posted: Thu Apr 03, 2014 2:54 pm
by 16458388
Hello Yeray,
thanks a lot for the links and infos. In the meantime I tried another way of printing with a preview panel:
I added the component TChartPreviewer to my project and started the preview pint dialog by something like this:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  PrintPreview.Chart:=Chart1;
  PrintPreview.Execute;
end;
However, the problem is, that the preview panel of this predefined form does not display any chart diagram, the page just remains white and printing produces an empty page. Even if I try the following, I get the same result:

Code: Select all

TeePreview(Self,Chart1);
Of course, the original chart1 contains a visible diagram. Do you have any idea, how to solve the problem?
And is there any possibility to translate the controls and captions of the Previewer form into other languages?

Re: Using TeePreviewPanel.Print and AsBitmap

Posted: Fri Apr 04, 2014 9:19 am
by yeray
Hi Andreas,
Andreas iCD wrote:I added the component TChartPreviewer to my project and started the preview pint dialog by something like this:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  PrintPreview.Chart:=Chart1;
  PrintPreview.Execute;
end;
However, the problem is, that the preview panel of this predefined form does not display any chart diagram, the page just remains white and printing produces an empty page.
Can't reproduce this with TeeChart v2014.10 in Delphi 2010. I've created a new project, dropped a TChart, a TButton and a TChartPreviewer component to the form. Note by default the TChartPreviewer is called ChartPreviewer1 so my code looks like this:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  ChartPreviewer1.Chart:=Chart1;
  ChartPreviewer1.Execute;
end;
And when I execute it, I see the chart in the preview as expected:
2014-04-04_1105.png
2014-04-04_1105.png (25.91 KiB) Viewed 18178 times
Andreas iCD wrote:Even if I try the following, I get the same result:

Code: Select all

TeePreview(Self,Chart1);
In the simple example above, I add a second TButton, TeePrevi unit to the uses clause and then I can call the code you mention. And I get the same correct result mentioned above.
Andreas iCD wrote:Of course, the original chart1 contains a visible diagram. Do you have any idea, how to solve the problem?
Check the paths in the IDE. There may be some path in the IDE or in the project pointing to an old installation.
Andreas iCD wrote:And is there any possibility to translate the controls and captions of the Previewer form into other languages?
Yes, you can translate all the editors with a single call. Ie:

Code: Select all

uses TeeTranslate, TeeCatalan;

procedure TForm1.FormCreate(Sender: TObject);
begin
  TeeSetCatalan;
end;

Re: Using TeePreviewPanel.Print and AsBitmap

Posted: Fri Apr 04, 2014 9:29 am
by 16458388
Hello again,
in the meantime I found out: The page panel of the TChartPreviewer component remains empty when the associated chart is in GDI+ mode. If I switch GDI+ off for the current chart, it is displayed in the preview panel and I can print it!

So, my remaining qeustions are:
- Is there any way to display and print even in GDI+ mode of the chart?
- Can I assign customized texts/translations for the controls and captions in this preview component?

Best regards,
Andreas

Re: Using TeePreviewPanel.Print and AsBitmap

Posted: Fri Apr 04, 2014 10:38 am
by 16458388
Hi Yeray,
sorry, when I posted my last replay, I didn't regcognize yet, that you already answered my question for translating the preview component. Now I tried it for German and it works very fine! Thank you very much!

best regards,
Andreas

Re: Using TeePreviewPanel.Print and AsBitmap

Posted: Fri Apr 04, 2014 11:17 am
by 16458388
Hopefully, just one question concerning the translation of the print preview panel:
In our chart application the user can decide between runig the tool in German or English language.
Switching to German langauge works fine, but how can I change back to the default (?) language English at runtime? I did not find a unit like "TeeEnglish" and the TeeChart 2013 help seesm to be little bit thin according to this subject.

Have a nice day,
Andreas

HelpContext for TChartPreviewer?

Posted: Fri Apr 04, 2014 12:29 pm
by 16458388
Hello once again,
do I have any chance to set a HelpContext ID to the Chart Previewer form? There is no property "HelpContext" for this component and even the following code line seems to have no effect on context related online help :

Code: Select all

  TForm(ChartPreviewer).HelpContext:=123;
  ChartPreviewer.Execute;
Any idea?

Re: Using TeePreviewPanel.Print and AsBitmap

Posted: Fri Apr 04, 2014 3:05 pm
by yeray
Hi Andreas,
Andreas iCD wrote:in the meantime I found out: The page panel of the TChartPreviewer component remains empty when the associated chart is in GDI+ mode. If I switch GDI+ off for the current chart, it is displayed in the preview panel and I can print it!

- Is there any way to display and print even in GDI+ mode of the chart?
I can't reproduce this problem here. I've tried it both with TeeChart v2013.08, v2013.09 and v2014.10.
Could you please specify the version you are using and attach a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
Andreas iCD wrote:Hopefully, just one question concerning the translation of the print preview panel:
In our chart application the user can decide between runig the tool in German or English language.
Switching to German langauge works fine, but how can I change back to the default (?) language English at runtime? I did not find a unit like "TeeEnglish" and the TeeChart 2013 help seesm to be little bit thin according to this subject.
To set English again you have to add TeeConst unit to the uses clause and set:

Code: Select all

TeeLanguage:=TeeEnglishLanguage;

Re: Using TeePreviewPanel.Print and AsBitmap

Posted: Mon Apr 07, 2014 11:14 am
by 16458388
Hello Yeray,
please forget about the GDI/GDI+ problem and invisible chart in TChartPreviewer. I think, it was jsut some kind of initialization errror for GDI+ within my project. When I switched off GDI+ and activated it once again within the same session, the preview even displays GDI+ charts.

But just some other questions for using the TChartPreviewer:

a) HelpContext ID for this component
As I already mentioned, I cannot find a way to adress a customized helpcontext ID to this component. Do you have any idea?

b) Events for changing settings within the preview dialog
The ShowBackground option (cpoPrintPanel) seesms to influence only a colored background or gradient but not a loaded background image of the chart. I tried to manage this by my own code using the PrintPreviewAfterDraw event to check the current state of of the previewer options (when a user switches the checkboxes of the control). However the following code does not work. It seems as if the states within the options set are not directly updated during user interaction:

Code: Select all

procedure TMainForm.PrintPreviewAfterDraw(Sender: TObject);
begin
  if cpoPrintPanel in PrintPreview.Options then
  begin
    if FileExists(ChartBackImageDefault) then
    begin
     TChart(PrintPreview.PreviewPanel.Panel).BackImage.LoadFromFile(ChartBackImageDefault);
    end;
  end
  else
  begin
    TChart(PrintPreview.PreviewPanel.Panel).BackImage.Graphic:=NIL;
  end;
end;
Any soluation for this problem?

Best regards,
Andreas

Re: Using TeePreviewPanel.Print and AsBitmap

Posted: Tue Apr 08, 2014 11:57 am
by yeray
Hello Andreas,
Andreas iCD wrote:do I have any chance to set a HelpContext ID to the Chart Previewer form? There is no property "HelpContext" for this component and even the following code line seems to have no effect on context related online help :

Code: Select all

  TForm(ChartPreviewer).HelpContext:=123;
  ChartPreviewer.Execute;
Any idea?
I'm sorry. I've missed this part. Please, read the instructions below on my signature. Note we recommend opening different threads to discuss about different subjects.
Andreas iCD wrote:a) HelpContext ID for this component
As I already mentioned, I cannot find a way to adress a customized helpcontext ID to this component. Do you have any idea?
I'm not sure to understand what components are you using nor what's the purpose of the code you posted above.
Note TChartPreviewer is a TComponent, not a TForm, so it doesn't have any HelpContext property.
Please, arrange a simple example project we can run as-is to reproduce the problem here.
Andreas iCD wrote:b) Events for changing settings within the preview dialog
The ShowBackground option (cpoPrintPanel) seesms to influence only a colored background or gradient but not a loaded background image of the chart. I tried to manage this by my own code using the PrintPreviewAfterDraw event to check the current state of of the previewer options (when a user switches the checkboxes of the control). However the following code does not work. It seems as if the states within the options set are not directly updated during user interaction:

Code: Select all

procedure TMainForm.PrintPreviewAfterDraw(Sender: TObject);
begin
  if cpoPrintPanel in PrintPreview.Options then
  begin
    if FileExists(ChartBackImageDefault) then
    begin
     TChart(PrintPreview.PreviewPanel.Panel).BackImage.LoadFromFile(ChartBackImageDefault);
    end;
  end
  else
  begin
    TChart(PrintPreview.PreviewPanel.Panel).BackImage.Graphic:=NIL;
  end;
end;
Any soluation for this problem?
I've reproduce the problem so I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=708

Feel free to add your mail to the CC list of the ticket to be automatically notified when an update arrives.