PDF Creator

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.

Theunis –

Did you ever find a solution?

We’ve been successfully using code similar to yours for several months. Suddenly, we seem to be suffering from the problem you describe. Our error message is “Invalid assignment. It is not possible to assign a _clsPDFCreatorOptions to a clsPDFCreatorOptions”.

I’ve noticed that version 0.9.9 has been released. Perhaps one of our people upgraded, and maybe there’s a compatibility problem between 0.9.8 and 0.9.9…

I’ll post again if I figure something out…

Regards,

  • Jamie

Hi Jamie,

In fact, I never found a serious and reliable solution (and neither one that is not serious or reliable)!

Since the problem kept coming back, I have created a solution that to my opinion is quite silly, but at least it works: when I compiled the object on some users’ PC’s I had problems using it for other users, and the other way around. What I did is that I more or less isolated the PDF-creator code in two separate codeunits, each having exaclty the same code. In the User Setup tabel, I added a field indicating which codeunit sould be used for which user. I compiled codeuni 1 on one PC, and codeunit 2 on another PC. Since the code is stored in a separate codeunit, I do not expect ever to have to re-compile them agian (and so far that is true). Since I do not re-compile, the objects now function well. Don’t ask me how or why this works, but it does work for a few months now.

I do not know whether, as you describe, the version of PDF-creator influences this problem. I could easily imagaine that that would be the case, but in my case it concerned users having the same OS, the same permissions, the same version of PDF Creator etc. Also re-installing the software, the registries, everything did not help. Fortunately I needed only two versions of the codeunit, since approx. 25 users are using the software. If they all needed a different codeunit, I don’t know what I would have done.

If you find a better solution, I am interested in hearing from you!

Have a nice day, Theunis.

The various versions of PDFCreator are not compatible. Make sure that everyone in the company has the exact same version of PDFCreator and make sure you also use that same version to compile the objects.

I am using either version 0.9.7 and have all my clients usign the same version. Tell your clients they MUST NOT upgrade PDF Creator.

There are some posts on Mibuso about this:

http://www.mibuso.com/forum/viewtopic.php?f=16&t=35052&hilit=pdfcreator

http://www.mibuso.com/forum/viewtopic.php?f=5&t=18331

I address this issue in one of those.

Also avoid the UNTIL (PDFCreator.cIsConverted) as this does not seem to work all the time.

Hi Theunis,

I have just come across your post and was supprised to hear you haven’t found a reliable solution. I believe you might be interested in a product called Spindle Professional. You can find more information here: http://www.draycir.com/spindle/index.php. If you have any questions please feel free to message me.