PDF Creator

I need to generate a PDF from report and i don`t know why the first time i execute the code is OK but when i change the name of the file and execute again the code it saves the report with the first name. Somebody knows what is wrong?

The code:

Window.OPEN(‘En proceso …’);
WindowIsOpen := TRUE;
IF _ArchivoPDF = ‘’ THEN
ERROR(Text001);

IF Objeto.GET(Objeto.Type::Report,’’,204) THEN BEGIN

IF ISCLEAR(PDFCreator) THEN BEGIN
CREATE(PDFCreator);
PDFCreator.cStart();
END;
IF ISCLEAR(PDFCreatorError) THEN
CREATE(PDFCreatorError);
PDFCreatorError := PDFCreator.cError;

PDFCreatorOptions := PDFCreator.cOptions;

PDFCreatorOptions.UseAutosave := 1;
PDFCreatorOptions.UseAutosaveDirectory := 1;
PDFCreatorOptions.AutosaveDirectory := _Directorio;
PDFCreatorOptions.AutosaveFormat := 0; //Formato PDF
PDFCreatorOptions.AutosaveFilename := _ArchivoPDF;

PDFCreator.cOptions := PDFCreatorOptions;
PDFCreator.cClearCache();
PDFCreator.cDefaultPrinter := TextPdfCreator;
PDFCreator.cPrinterStop := FALSE;
REPORT.RUNMODAL(_ReportID,FALSE,TRUE,_SalesHeader);
PDFCreatorOptions.SaveFilename(‘File 1’);
PDFCreator.cClose();
CLEAR(PDFCreator);
Window.CLOSE;
END;

Where and how do you set ‘File 1’ ?

you need to move out PDFCreator.cStart(); out of if statement?

I resolved it. I forgot to save options and when i execute the code the options are always the estandar. The code is like this:

Window.OPEN(‘En proceso …’);
WindowIsOpen := TRUE;
IF _ArchivoPDF = ‘’ THEN
ERROR(Text001);

IF Objeto.GET(Objeto.Type::Report,’’,204) THEN BEGIN

IF ISCLEAR(PDFCreator) THEN BEGIN
CREATE(PDFCreator);
PDFCreator.cStart();
END;
IF ISCLEAR(PDFCreatorError) THEN
CREATE(PDFCreatorError);
PDFCreatorError := PDFCreator.cError;

PDFCreatorOptions := PDFCreator.cOptions;

PDFCreatorOptions.UseAutosave := 1;
PDFCreatorOptions.UseAutosaveDirectory := 1;
PDFCreatorOptions.AutosaveDirectory := _Directorio;
PDFCreatorOptions.AutosaveFormat := 0; //Formato PDF
PDFCreatorOptions.AutosaveFilename := _ArchivoPDF;

PDFCreator.cOptions := PDFCreatorOptions;

//TO SAVE OPTIONS

PDFCreator.cSaveOptions(PDFCreatorOptions);

PDFCreator.cClearCache();
PDFCreator.cDefaultPrinter := TextPdfCreator;
PDFCreator.cPrinterStop := FALSE;
REPORT.RUNMODAL(_ReportID,FALSE,TRUE,_SalesHeader);
PDFCreatorOptions.SaveFilename(‘File 1’);
PDFCreator.cClose();
CLEAR(PDFCreator);
Window.CLOSE;
END;

Thanks[:D]

what type and subtype you use for variables PDFCreator, PDFCreatorError and PDFCreatorOptions?

hi

Name DataType Subtype

PDFCreator Automation ‘PDFCreator’.clsPDFCreator
PDFCreatorOption Automation ‘PDFCreator’.clsPDFCreatorOptions
PDFCreatorError Automation ‘PDFCreator’.clsPDFCreatorError

they are automations

PDFCreator is ‘PDFCreator’.clsPDFCreator

PDFCreatorError is ‘PDFCreator’.clsPDFCreatorOptions

PDFCreatorOptions is ‘PDFCreator’.clsPDFCreatorError

hi

Dear Yogesh Kumar can you tell me wich type of dll (Automation ) I should use to declaire following variables

PDFCreator Automation ‘PDFCreator’.clsPDFCreator
PDFCreatorOption Automation ‘PDFCreator’.clsPDFCreatorOptions
PDFCreatorError Automation ‘PDFCreator’.clsPDFCreatorError