Invalid index. Please check the index parameter

Hello friends
sorry but i need help
I have this code in Delphi but this occurs an error (Invalid index Please check the index parameter.) in the job code: = PDFObject.NextJob;

PDFObject: CreateOleObject = (‘PDFCreator.JobQueue’);
PDFObject.Initialize;
if DataModule1.ambientecte = ‘APPROVAL’ then
Filename: = 'c: \ temp ’ + Qprincipalcodcon.AsString + ‘. pdf’
else
Filename: = 't: \ public \ DRAFT ’ Qprincipalcodcon.AsString + +; ‘pdf.’
Relatorio.PrinterSetup.Copies: = 1;

if not PDFObject.WaitForJob (10) then
showmessage (‘The print job does not reach the line within 10 seconds’)
else
begin
job: = PDFObject.NextJob;
job.ConversionProfileByGuid: = ‘DefaultGuid’;
job.ConvertTo (filename);
end;
Relatorio.TextFileName: = filename;
Relatorio.Print;

Hi,

please try inverting the logic of your if statement, e.g.
if PDFObject.WaitForJob (10) then
begin
job: = PDFObject.NextJob;
job.ConversionProfileByGuid: = ‘DefaultGuid’;
job.ConvertTo (filename);
end;
Relatorio.TextFileName: = filename;
Relatorio.Print;
else
showmessage (‘The print job does not reach the line within 10 seconds’)

Best regards,

Robin

hello friends, I would like to receive more tip, because I am not able to do, how to not show the box to save the file (automatically saved with the name and path specified by me through the system) and not appear the file view. Sincerely Carlos

Hi,

my first guess is it might be caused by Relatorio.Print;
If you don’t intend to print the file out on a hardware printer afterwards, don’t use this command.
If you do use it, make sure PDFCreator isn’t your default printer. Or do you already get a save dialog on the step
job.ConvertTo (filename);?

Best regards,

Robin

hello Robin I am forced to use the Relatorio.print command because the report does not yet exist (it is generated by the application) and the PDFCreator is not the default printer
Best regards
Carlos