Link to home
Start Free TrialLog in
Avatar of DeMortagne
DeMortagne

asked on

Acrobat Distiller and C#

Hello with you all, please excuse me for my English, but it is not famous. A French version of the message is lower. I have a small problem of use with Acrobat Distiller. In a project C #, I have to create a reference to the ACRODISTXLib object. It is possible for me to use the following function: FileToPDF as well as the events OnJobDone and OnJobFail. However, I have a problem when I tests to make carry out the whole for more than one file postscript. The treatment for the first file is carried out correctly, but for the second and the following ones, it plants. Here the code which I use:

int laLongueur = leFichier.Length;
string leFichierN = leFichier.Substring(0, (laLongueur - CNDCAP(leFichier)));    
ACRODISTXLib.PdfDistiller pdf = new ACRODISTXLib.PdfDistillerClass();
pdf.OnJobDone += new _PdfEvents_OnJobDoneEventHandler(PDFOnJobDone);
pdf.OnJobFail += new _PdfEvents_OnJobFailEventHandler(PDFOnJobFail);

try {                        
pdf.FileToPDF(deOu + leFichier, versOu + leFichierN + ".pdf", " ");                    
}
catch {
EcritureErreur(leFichier, "Création du PDF1");    
File.Copy(deOu + leFichier, versNnV + leFichier, true);
File.Delete(deOu + leFichier);
}

the error which it gives in the try is the error 1410, the class already exists of acrobat. In other words, Distiller is an already instancier when one returns second once. therefore, which would be the means to launch the garbagecollector in order to make disparaitre this authority or if you have another solution.
thank you
Sebastien
---------version in french----------
Bonjour à vous tous, veuillez m'excuser pour mon anglais, mais il n'est pas fameux. Une version française du message est plus bas.

J'ai un petit problème d'utilisation avec Acrobat Distiller.
Dans un projet c#, j'ai créer une référence à l'objet ACRODISTXLib. Il m'est possible d'utiliser la fonction suivante : FileToPDF
ainsi que les événements OnJobDone et OnJobFail.

Cependant, j'ai un problème lorsque j'essais de faire exécuter le tout pour plus d'un fichier postscript.
Le traitement pour le premier fichier s'exécute correctement, mais pour le deuxième et les suivantes, il plante.
Voici le code que j'utilise :
int laLongueur = leFichier.Length;
string leFichierN = leFichier.Substring(0, (laLongueur - CNDCAP(leFichier)));

ACRODISTXLib.PdfDistiller pdf = new ACRODISTXLib.PdfDistillerClass();
pdf.OnJobDone += new _PdfEvents_OnJobDoneEventHandler(PDFOnJobDone);
pdf.OnJobFail += new _PdfEvents_OnJobFailEventHandler(PDFOnJobFail);

try {                        
pdf.FileToPDF(deOu + leFichier, versOu + leFichierN + ".pdf", " ");                    
}
catch {
EcritureErreur(leFichier, "Création du PDF1");    
File.Copy(deOu + leFichier, versNnV + leFichier, true);
File.Delete(deOu + leFichier);
}              

L'erreur qu'il donne dans le try est l'erreur 1410, La classe existe déjà. d'acrobat.
En d'autres mots, Distiller est déjà instancier lorsqu'on revient une deuxième fois.

donc, quelle serait le moyen pour lancer le garbagecollector afin de faire disparaitre cette instance ou si vous avez une autre solution.

merci
Sébastien
ASKER CERTIFIED SOLUTION
Avatar of Nebulus_
Nebulus_

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I added a class that has a distiller member

this class is singleton, it works fine !!

Thanks,

:)