Printing to PDF using built-in Windows PDF driver without prompting for a filename requires a simple additional step:
C# / .NET
TGIS_PrintManager printman = new TGIS_PrintManager();
PrintDocument printdoc = new PrintDocument()
{
PrinterSettings = new PrinterSettings()
{
PrinterName = "Microsoft Print to PDF",
PrintToFile = true,
PrintFileName = @"c:\Temp\myfile.pdf"
)
};
TGIS_Printer printer = new TGIS_Printer( printdoc );
printman.Print( GIS, printer );
Delphi /VCL
var
hprinter : THandle;
sdevice,
sdriver,
sport : array[0..80] of Char;
oprinter : TGIS_Printer ;
oprintman: TGIS_PrintManager ;
begin
Printer.PrinterIndex := Printer.Printers.IndexOf('Microsoft Print to PDF');
Printer.GetPrinter( sdevice, sdriver, sport, hprinter ) ;
Printer.SetPrinter( sdevice, sdriver, 'C:\Temp\myfile.pdf', 0);
oprintman := TGIS_PrintManager.Create ;
try
oprinter := TGIS_Printer.Create( Printer ) ;
try
oprintman.Print( GIS, oprinter ) ;
finally
oprinter .Free ;
end;
finally
oprintman.Free ;
end ;
end;