Page 1 of 1

TChart3D printing does not work

Posted: Thu Jul 10, 2014 12:31 pm
by 16566563
Hi,

I've been trying to print a TChart3D using either TChart3D.Printlandscape, PrintPortrait, or PrintPartialcanvas, but unfortunately the printed page is always empty. I tried a few different printers (Kyocera FS1370DN, some pdf printers including adobe's and the microsoft XPS printer). Saving the chart to a bitmap file, or copying to the clipboard however is working fine...


Code: Select all

Chart3D.PrintLandscape
or by printing to the printer.canvas manually:

Code: Select all

Printer.BeginDoc;
Printer.Canvas.TextOut(50, 50, 'printing test text');
Chart3D.PrintPartialCanvas(Printer.Canvas, Rect(100, 100, 2000, 2000));
Printer.EndDoc;

In the above example the "printing test text" line is printed as expected - but no chart in either of the two examples...

Do I have to prepare the chart for printing ?
Furthermore the call of any of the TChard3D's printing methods erases the chart3d's client area - it shows up as a completely white area - a full redraw has to be performed to show the Tchart as it was showign before calling any of the printing methods ?

Best regards,

Klaus

Re: TChart3D printing does not work

Posted: Thu Jul 10, 2014 1:39 pm
by narcis
Hi Klaus,
Do I have to prepare the chart for printing ?
No, this looks like a bug to me. I have added it to the bug list (ID838). The only way I found it works (as a standard chart, non-TChart3D) is opening the chart editor and going through the print preview in the editor for printing the chart. Using StretchDraw doesn't work either:

Code: Select all

uses Printers;

procedure TForm1.Button1Click(Sender: TObject);
var meta : TMetafile;
begin
   Chart3D1.BevelOuter := bvNone;
   Meta := Chart3D1.TeeCreateMetafile(True, Chart3D1.ClientRect);
   try
      Printer.Orientation := poPortrait;
      Printer.BeginDoc;
      try
         Printer.Canvas.StretchDraw(Rect(1,1,Printer.PageWidth - 1,
         Printer.PageHeight - 1),Meta);
      finally
         Printer.EndDoc;
      end;
   finally
      Meta.Free;
      Chart3D1.BevelOuter := bvRaised;
   end;
end;
Furthermore the call of any of the TChard3D's printing methods erases the chart3d's client area - it shows up as a completely white area - a full redraw has to be performed to show the Tchart as it was showign before calling any of the printing methods ?
No, I could reproduce it also.

BTW, feel free to sign up at bugzilla and add yourself to the CC List to receive automatic issue notifications.

Re: TChart3D printing does not work

Posted: Sun Jul 28, 2019 2:25 am
by 16486684
The work around is very simple. Copy the TChart3D canvas to another canvas that does work, and print the copied canvas. I used a TImage canvas in my example. I had to include the zero length line draw as a workaround to get the TImage canvas to print, so the example has two workarounds to get TDraw3D to print. Taken together, the TDraw3D print process does work.

Code: Select all

                        Draw3D1->CopyToClipboardBitmap();
			Image3D->Visible = true;
			Image3D->Align = alClient;
			Image3D->Picture->Assign(Clipboard());

                        Printer()->Title = "Picture 3D";
			Printer()->BeginDoc(); 
			Printer()->Canvas->Pen->Width = 1;
			Printer()->Canvas->Pen->Color = clWhite;
			Printer()->Canvas->MoveTo(0,0); Printer()->Canvas->LineTo(0,0);        //Need this as a bug work-around
			Printer()->Canvas->CopyRect(
                                     Rect(0, 0, Printer()->PageWidth, Printer()->PageHeight), 
                                     Image3D->Canvas, 
                                     Rect(0, 0, Image3D->Width, Image3D->Height));

			Printer()->EndDoc();
			Image3D->Visible = false;
			Image3D->Align = alNone;

Re: TChart3D printing does not work

Posted: Mon Aug 12, 2019 7:18 am
by Marc
Thanks for the input.

Regards,
Marc