PDFCreator v2.1 and Delphi 7

to execute code in the purple line skip this error: invalid index. Please check the index parameter.
I guess the error comes from the previous line which replaced by 'LQueue.WaitForJobs (3);', but the error continues to be generated.

I need help :(

Here I attached the code I'm using.


procedure TForm1.btn2Click(Sender: TObject);
var
  LQueue: IQueue;
  LPrintJob: IPrintJob;
  LPDFCreator: IPDFCreator;
begin
 // LPDFCreator:= CoPdfCreatorObj.Create;

  LQueue := coQueue.Create;
  LQueue.Initialize;

  //LPrintJob := CoPrintJob.Create;

  LQueue.WaitForJobs(1,3);
  LPrintJob := LQueue.NextJob;
  LPrintJob.SetProfileByGuid('DefaultGuid');
  LPrintJob.ConvertTo('C:\\test.pdf');

  LQueue.ReleaseCom;
end;

Hello,


for only one printjob please try the WaitForJob method.
Also please try to use a longer timeout e. g. something between 10 and 20 seconds.

best regards,

Cay

Hello Cay, 

the error ‘invalid index. Please check the index parameter.’ continue to show in line 
LPrintJob := LQueue.NextJob; I’ve tried several codes but no results and online help is scarce. 

i need to help.

Hi,


did you check if the job actually arrived within the given timeout?
I haven’t used Delphi in ages so I don’t know the synthax, in JS a check would look something like like :
if(!PDFCreatorQueue.WaitForJob(10))
{
WScript.Echo(“The print job did not reach the queue within 10 seconds”);
}
<pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(68, 68, 68); line-height: 22.3999996185303px; text-align: justify;"><br>

```

Yes, Robin. But actually I did that validation error persists mostrandose on screen, and what initially want to do is to convert a document to PDF .xlsx.

attached the code I’ve been implementing and changing lately:
procedure TForm1.btn2Click(Sender: TObject);
var
  LQueue: IQueue;
  LPrintJob: IPrintJob;
  LPDFCreator: IPDFCreator;
  LPrinter: IPrinters;
begin

    LPDFCreator:= CoPdfCreatorObj.Create; //creo el objeto pdfCreator
    LPrinter:= CoPrinters.Create; //creamos el Printers
    LPrinter.GetPrinterByIndex(0);  //Retorna el nombre de la impresora con el indice correspondiente
    LPrinter:= LPDFCreator.GetPDFCreatorPrinters; //metemos un objeto Printer en la variable LPrinter
   // LPDFCreator.PrintFile(‘C:\taty.xlsx’);
    LQueue:= CoQueue.Create;
    LQueue.Initialize;
    //LPrintJob := CoPrintJob.Create;
 { if not (LQueue.WaitForJob(10)) then
    ShowMessage(‘The print job did not reach the queue within 10 seconds’);     }
    LQueue.WaitForJob(15);
    LPrintJob := LQueue.NextJob;
    LPrintJob.SetProfileByGuid(‘DefaultGuid’);
    LPrintJob.ConvertTo(‘C:\tatys.pdf’);


    LQueue.ReleaseCom;