Templot Club forums powered for Martin Wynne by XenForo :

TEMPLOT 3D PLUG TRACK - To get up to speed with this experimental project click here.   To watch an introductory video click here.   See the User Guide at Bexhill West.

   Templot5 - To join this open-source project on GitHub click here.  For news of the latest on-going developments click here.  Templot5 is now included with Templot2 - download.        WIKI

  • The Plug Track functions are experimental and still being developed. Some of the earlier pages of this topic are now out-of-date.

    For an updated overview of this project see this topic.   For some practical modelling aspects of using Plug Track see Building 3D Track.

    The assumption is that you have your own machines on which to experiment, or helpful friends with machines. Please do not send Templot files to commercial laser cutting or 3D printing firms while this project is still experimental, because the results are unpredictable and possibly wasteful.

    Some pages of this and other topics include contributions from members who are creating and posting their own CAD designs for 3D printing and laser-cutting. Do not confuse them with Templot's own exported CAD files. All files derived from Templot are © Martin Wynne.
  • The Plug Track functions are experimental and still being developed.

    For an updated overview of this project see this topic.   For some practical modelling aspects of using Plug Track see Building 3D Track.

    The assumption is that you have your own machines on which to experiment, or helpful friends with machines. Please do not send Templot files to commercial laser cutting or 3D printing firms while this project is still experimental, because the results are unpredictable and possibly wasteful.

    Some pages of this and other topics include contributions from members who are creating and posting their own CAD designs for 3D printing and laser-cutting. Do not confuse them with Templot's own exported CAD files. All files derived from Templot are © Martin Wynne.

Error when printing template details

Quick reply >

Vistisen

Member
Location
Denmark
I get this error when I try to print template details. It comes after clicking print in the printer dialogue window- I am using Templot 5. the latest build.

Screenshot 2024-11-17 181749.png


I do not get the error if I create a pdf... but I do not get an PDF either! The templot pdf folder is empty
 
_______________
message ref: 15063
Last edited:
@Vistisen @Steve_Cornford

Hi Tim, Steve,

This problem is caused by the fact that the HtmlViewer component (originally written for Delphi) uses EMF metafiles to create the print output.

EMF metafiles are not supported in Lazarus, so the print function fails.

We have created our own workaround for EMF metafiles in Templot5, but incorporating it into the HtmlViewer package is no 5-minute task. I have too many other distractions at present, so I'm going to leave this for now and add it to the to-do list. The same applies to the PDF output.

For the present I have now commented out these two functions, suggesting swapping back to Templot2 if they are needed. Sorry this wasn't done before releasing Templot5. Thanks for reporting it.

A more practical solution would be to click the options... button and then copy all text. Which can then be pasted into any editor such as Windows Notepad for printing. But note that this won't include any images.

This problem also applies to several other functions in Templot which use the HtmlViewer, such as printing a list of the storage box contents. I will look at creating an alternative printing function for them in the short-term.

This is one of several loose ends still to be fixed before Templot5 can fully replace Templot2.

cheers,

Martin.
 
_______________
message ref: 15130
Hi Martin,
But the [ create PDF] button on the Help screen works ok so perhaps leave that in?
Steve
@Steve_Cornford

Hi Steve,

???

Have you fixed it and not merged it?

Here the button works in that it doesn't crash and shows the PDF file save dialog. But no file gets created -- it is all still commented out in the original conversion to get Lazarus to compile:

Code:
procedure Thelp_form.pdf_buttonClick(Sender: TObject);

var
 //OT2024  metafile_printer:TMetafilePrinter;
  page:integer;
  folder_str:string;

begin
  num_of_print_pages:=html_view.NumPrinterPages;   // for print header

  with save_file_dialog do begin
    InitialDir:=exe_str+'PDF-FILES\';
    FileName:=remove_invalid_str(Copy(Trim(help_form.Caption),1,24)+FormatDateTime('_yyyy_mm_dd_hhmm_ss',Date+Time))+'.pdf';
    Title:='    save  PDF  file  as ...';

    showing_dialog:=True;   // 212a Wine bug

    if Execute=False
       then begin
              showing_dialog:=False;   // 212a Wine bug
              EXIT;
            end;

    showing_dialog:=False;   // 212a Wine bug       

          // invalid entered chars removed by dialog

// OT2024    html_pdf_printer.FileName:=ExtractFilePath(FileName)+lower_case_filename(ExtractFileName(FileName));   // to underscores and lower case

  end;//with

  showing_dialog:=True;   // 212a Wine bug

(* // OT2024

  if pdf_setup_dialog.Execute=False
     then begin
            showing_dialog:=False;   // 212a Wine bug
            EXIT;
          end;

  showing_dialog:=False;   // 212a Wine bug

  metafile_printer:=TMetafilePrinter.Create(Self);

  try
    html_view.PrintPreview(metafile_printer);

    html_pdf_printer.BeginDoc;
    try
      for page:=0 to metafile_printer.LastAvailablePage-1 do begin

        html_pdf_printer.StartPage(metafile_printer.PageWidth,metafile_printer.PageHeight,metafile_printer.PixelsPerInchX,metafile_printer.PixelsPerInchY,0);
        html_pdf_printer.Canvas.Draw(0,0,metafile_printer.MetaFiles[page]);
        html_pdf_printer.EndPage;

      end;//for
    finally
      html_pdf_printer.EndDoc;
    end;
  finally

    if alert(2,'    PDF  file  created',
               ' |PDF file created ( '+IntToStr(num_of_print_pages)+' pages ):'
              +'||'+ExtractFileName(html_pdf_printer.Filename)
              +'||  page width: '+IntToStr(metafile_printer.PageWidth)+' dots at '+IntToStr(metafile_printer.PixelsPerInchX)+' dots per inch'
              +'||page height: '+IntToStr(metafile_printer.PageHeight)+' dots at '+IntToStr(metafile_printer.PixelsPerInchY)+' dots per inch|| ',
               '','','','open  the  containing  folder','','continue',0)=4
       then begin
              folder_str:=ExtractFilePath(html_pdf_printer.Filename);

              if ShellExecute(0,'explore',PChar(folder_str),nil,nil,SW_SHOWNORMAL)<=32
                 then show_modal_message('Sorry, unable to open the folder.')
                 else external_window_showing:=True;
            end;

    metafile_printer.Free;
  end;//try

*)

end;

I have changed it to:

Code:
begin
  do_open_source_bang('PDF Help Notes');  // OT2024
  EXIT; // OT2024

And similarly for the print button.

Which I should have done originally.

cheers,

Martin.
 
_______________
message ref: 15143
Hi Martin,
Yes sorry you are right, it does show the create PDF dialog screen, but as you say nothing actually gets created.

Are we aiming to make Templot5 platform independent?

Steve
 
_______________
message ref: 15146
Are we aiming to make Templot5 platform independent?
@Steve_Cornford

Hi Steve,

Who is this "we"? :)

I'm not -- I don't know enough about any platform other than Windows to know what I'm doing.

But part of the reason for going open-source is that others may want to do that. Someone (sorry, forgotten who) did post a while ago to say that he had got the original 2018 code running natively on a Mac, sort of.

As you know, for Windows stuff not supported in Lazarus I have created helper executables using Delphi. Which means T5 will be Windows-only (or via Wine/CrossOver).

If someone creates a version for some other platform it will need its own name, such as TemplotMac. I would be a bit annoyed if someone created a version of Templot with bits missing for other platforms, and still called it Templot5.

cheers,

Martin.
 
_______________
message ref: 15147
Back
Top