I am experiencing problems with the usage of PDF Creator in combination with MBS Dynamics NAV (Version NL 5.01). The code that I am using is (more or less) similar to the code that you can find on various websites. Here’s my code:
Just before I print a report I call the following function:
PDFCreatorStart
IF ISCLEAR(PDFCreator) THEN
CREATE(PDFCreator);
IF ISCLEAR(PDFCreatorError) THEN
CREATE(PDFCreatorError);
PDFCreatorError := PDFCreator.cError;
IF PDFCreator.cStart(’/NoProcessingAtStartup’,TRUE) = FALSE THEN
ERROR(
‘Status: Error[’ + FORMAT(PDFCreatorError.Number) + ']: ’ + PDFCreatorError.Description);
PDFCreatorOptions := PDFCreator.cOptions;
SavePDFCreatorOptions := PDFCreator.cOptions;
PDFCreatorOptions.AutosaveDirectory := UseFileDir;
PDFCreatorOptions.AutosaveFilename := UseFileName;
PDFCreatorOptions.UseAutosaveDirectory := 1;
PDFCreatorOptions.UseAutosave := 1;
PDFCreatorOptions.AutosaveFormat := 0; // PDF file, you can also save in other formats
PDFCreator.cOptions := PDFCreatorOptions;
PDFCreator.cSaveOptions(PDFCreatorOptions);
PDFCreator.cClearCache();
DefaultPrinter := PDFCreator.cDefaultPrinter;
PDFCreator.cDefaultPrinter := ‘PDFCreator’;
PDFCreator.cPrinterStop := FALSE;
PDFCreator.cIsConverted := FALSE;
N.B.: UseFileDir and UseFilename are the local variables with which the function is called and that provide the name of the file and the directory to store to. I am using the Envirion command to retrieve the TEMP-directory for the user as the directory to save. After printing the report I am using the following code:
PDFCreatorFinish:
REPEAT
SLEEP(100);
WaitTime := WaitTime + 100;
UNTIL (PDFCreator.cIsConverted) OR (WaitTime >= 10000);
PDFCreator.cOptions := SavePDFCreatorOptions;
PDFCreator.cSaveOptions(SavePDFCreatorOptions);
// Restore Default Printer
PDFCreator.cDefaultPrinter := DefaultPrinter;
PDFCreator.cClearCache();
PDFCreator.cPrinterStop := FALSE;
IF NOT PDFCreator.cIsConverted THEN
ERROR(Text040);
CLEAR(PDFCreator);
CLEAR(PDFCreatorError);
My problem is the reliability of the functionality. I am using version PDFCreator-0_9_8. After installing the PDFCreator software, I sometimes (why not always?) have to re-compile the object on the PC of the person for which I have installed it. Sometimes al goes well for a couple of days, and then the user gets the message: A _clsPDFCreatorOptions cannot be assigned to _clsPDFCreatorOptions. If I then re-compile the object for that specific user it works again, but mostly for again a few days, after which the same problem arises. Does anyone have any suggestions how to make PDFCreator in combination with MBS Dynamics NAV more reliable? Or is it better to use another application anyhow? Thanks in advance for your comments.