How to implement PDFCreator options with COM objects

konfuncio

New Member
Hi!

I am trying to change word documents to PDF by changing the active printer to the PDF Creator one. It works fine, but I have to deal with the options programatically because in some cases I want the PDF to be shown and in some cases I want it to be just saved as a file. This is the code that is supposed to do this:

CREATE "PDFCreator.clsPDFCreator" hPDFJob.
/*IF hPDFJob:cStart('/NoProcessingAtStartup',-1) = 0 THEN DO:
MESSAGE "error"
VIEW-AS ALERT-BOX ERROR TITLE CURRENT-WINDOW:TITLE.
RELEASE OBJECT hPDFJob NO-ERROR.
RETURN.
END. */

ASSIGN hPDFJob:cOption("UseAutosave") = 1
hPDFJob:cOption("AutoSaveFormat") = 0
hPDFJob:cOption("AutosaveStartStandardProgram") = 0
hPDFJob:cOption("AutosaveDirectory") = SESSION:TEMP-DIRECTORY
chTexto = STRING(TODAY,"99-99-9999") + STRING(TIME) + ".pdf"
hPDFJob:cOption("AutosaveFilename") = chTexto

hPDFJob:cClearCache.
RELEASE OBJECT hPDFJob NO-ERROR.

wNomAplic:ActivePrinter = "PDFCreator".
{wImpDoc.i} /* Prints out through word */

The portion of code hPDFJob:cOption("UseAutosave") = 1 should select the autosave mode and hPDFJob:cOption("AutosaveStartStandardProgram") = 0 is the responsible one to select whether the document will be opened or not after autosaving.

But none of this options set programatically seems to work and the behaviour of the PDFCreator is the standard one.

Do you know how to set this options properly?

I am using Open Edge 10.1C and PDFCreator 0.9.9.

Many thanks in advance!
 
Re: But none of this options set programatically seems to work and the behaviour of the PDFCreator is the standard one.
>>How do you know that they are NOT being set on-the-fly , how can you be so sure?? Work through, STEP by STEP until you can put a tick by each attribute you require, not just asuming it is true. When you can see it with your own eyes, then you can tick that attribute. It is a slow process, but that is how you realize solutions.
 

Albor

New Member
hi.

example:
CREATE "PDFCreator.clsPDFCreator" hPDFJob.

IF hPDFJob:cStart('/NoProcessingAtStartup', -1) = 0 THEN DO:
MESSAGE "El sistema no pudo ejecutar el PDFCreator"
VIEW-AS ALERT-BOX ERROR TITLE CURRENT-WINDOW:TITLE.
RELEASE OBJECT hPDFJob NO-ERROR.
RETURN.
END.

hPDFJob:cStart("/NoProcessingAtStartup", -1).
hPDFJob:cOption("AutosaveDirectory").
hPDFJob:cOption("AutosaveFilename").
ASSIGN
hPDFJob:cOption("AutosaveStartStandardProgram") = 1
hPDFJob:cOption("UseAutosave") = 1
hPDFJob:cOption("UseAutosaveDirectory") = 1
hPDFJob:cOption("AutosaveFormat") = 0
hPDFJob:cPrinterStop = NO
hPDFJob:cVisible = NO.
DefaultPrinter = hPDFJob:cDefaultPrinter.
hPDFJob:cDefaultPrinter = "PDFCreator".
hPDFJob:cClearCache().
hPDFJob:cOption("AutosaveStartStandardProgram").
hPDFJob:cOption("AutosaveDirectory") = "d:\".
hPDFJob:cOption("AutosaveFilename") = "Archivo.txt".
hPDFJob:cVisible().
hPDFJob:cPrintfile("d:\archivo.txt").
hPDFJob:cDefaultPrinter = DefaultPrinter.
hPDFJob:cPrinterStop().


RELEASE OBJECT hPDFJob NO-ERROR.

see you
 

konfuncio

New Member
Thanks, but finally I managed to solve this and it works, more or less. I don´t really remember the code, but it looks to me that is very similar than this one.

Anyway, I realized that the behaviour is not very stable, but I don´t know if that is because of my code or because there´s not much more to do with this. For example, although I have set the option visible to no, sometimes and with some users PDF creator prompts its message to print or save, or directly shows the PDF up. Another example of this not desirable behaviour is the way it saves the file, so that it doesn´t save it always in the location I set it for it.

Do one of you fight against this kind of strange behaviour?

Regards.
 
Top