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;