PDF autosave w/Delphi

Hello everybody,

I finally found out how to call PDFCreator functions from Delphi, but there ar things that are not working to me.

This is my code:

`procedure ImprimirContrato(IdContrato : TIdentificador);
var PdfCreator : TclsPDFCreator;
    PdfCreatorOptions : TclsPDFCreatorOptions;
    ImpresoraXDefecto, ImpresoraPDF : String;
    ImprimirEnPDF : Boolean;
    wordapp, worddoc, rango, Tabla : variant;
    campo, ficheroplantilla : string;`

`begin
  ImpresoraPDF := 'PDFCreator';
  PdfCreator := TclsPDFCreator.Create(nil);
  try
//    PdfCreator.AutoConnect := true;
    PdfCreator.cStart('',false);
    ImpresoraXDefecto := PdfCreator.cDefaultPrinter;
    Showmessage(ImpresoraXDefecto);
    ImprimirEnPDF := PdfCreator.cPrinterIsInstalled(ImpresoraPDF);
    try
    if ImprimirEnPDF then
    begin
      PdfCreator.cDefaultPrinter := ImpresoraPDF;
//      PdfCreator.cPrinterProfile(ImpresoraPDF, 'Default');
      Showmessage(PdfCreator.cPrinterProfile[ImpresoraPDF]);`


`PrinterProfile shows blank string. The Let property line is commented because property doesn't admit 2 parameters.`


`      PdfCreator.cOptions := PdfCreator.cReadOptions('');
      with PdfCreator.cOptions do
      begin
        AutosaveDirectory := CaminoContratos;
        AutosaveFilename := 'Documento';
        AutosaveFormat := 0;
        AutosaveStartStandardProgram := 1;
        UseAutosave := 1;
        UseAutosaveDirectory := 1;
      end;
      PdfCreator.cSaveOptions(PdfCreator.cOptions,'');
    end;`


`Parameters MUST be passed to cSaveOptions when doc says it's optional.`


`  ficheroplantilla := 'administracion\\V-Contrato Previsonor 2k10.dot';
  if SeleccionaPlantilla(CaminoPlantillas, ficheroplantilla)  then
  begin
        fEspereUnMomento := TfEspereUnMomento.Create(nil);
        try
        fEspereUnMomento.Show;
        wordapp := CreateOleObject('Word.Application');
        try
          wordapp.Documents.add(ficheroplantilla);
          worddoc := wordapp.ActiveDocument;
          Rango := WordDoc.Content;
          campo := IntToStr(1539888);
          Rango.Find.Execute('{ETVS.ID}',false,true,false,false,false,true,
                             wdFindStop, false, campo, wdReplaceAll);
          campo := gDelegacion;
          Rango.Find.Execute('{DELEGACION}',false,true,false,false,false,true,
                             wdFindStop, false, campo, wdReplaceAll);`

`          campo := FormatDateTime('d "de" mmmm "de" yyyy', now);
          Rango.Find.Execute('{FECHACRTOLARGO}',false,true,false,false,false,true,
                             wdFindStop, false, campo, wdReplaceAll);
          campo := FormatDateTime('dd/mm/yyyy', now);
          Rango.Find.Execute('{FECHACRTOCORTA}',false,true,false,false,false,true,
                             wdFindStop, false, campo, wdReplaceAll);
          WordApp.Visible := true;`

`          if ImprimirEnPDF then
          begin
            worddoc.Printout(, , wdprintalldocument);
            worddoc.close(wdDoNotSaveChanges);
            wordapp.quit;
          end;`


`Finally Option Dialog comes out. So default printer does go to PDFCreator printer, but auto save options don't work.`


 

`        finally
          WordDoc := Unassigned;
          WordApp := Unassigned;
        end;
        finally
          fEspereUnMomento.Close;
        end;
  end;
    finally
      if ImprimirEnPDF then
        PdfCreator.cDefaultPrinter := ImpresoraXDefecto;
    end;
    PdfCreator.cClose;
  finally
    PdfCreator.Free;
  end;
end;
`


Anybody can give me some help of what I'm doing wrong?

 

Thanks.