Bonjour à tous,

J'essaye de convertir un .doc vers un .pdf dans mon application, seulement je n'y arrive pas. Ma solution consistait a changer l'imprimante par défaut de word et de mettre l'imprimante "virtuelle" de cute pdf à la place et d'invoquer ensuite l'impression du document. Cela me génere bien un .pdf à l'endroit voulu, mais celui ci est illisible !

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
public void ImprimerFichierWord(object fileName, Boolean visible, int NbCopies)
    {
        try
        {
            Microsoft.Office.Interop.Word._Application aWord;
            Microsoft.Office.Interop.Word._Document aDoc;
            aWord = new Microsoft.Office.Interop.Word.Application();
            aWord.Visible = visible;
            object Missing = System.Reflection.Missing.Value;
            aDoc = aWord.Documents.Open(ref fileName, ref Missing, ref Missing, ref Missing, ref  Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing, ref Missing);//, ref Missing);
            object myTrue = true;
            object myFalse = false;
 
            object missingValue = Type.Missing;
            object range = Microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintAllDocument;
            object items = Microsoft.Office.Interop.Word.WdPrintOutItem.wdPrintDocumentContent;
            object copies = NbCopies;
            object pages = "1";
 
            string imprimante = aWord.ActivePrinter;
            aWord.ActivePrinter = "CutePDF Writer";
            //aWord.ActivePrinter = "PDFCreator";
 
            object filePath = fileName.ToString() + ".pdf";
            object pageType = Microsoft.Office.Interop.Word.WdPrintOutPages.wdPrintAllPages;
 
 
 
 
 
 
 
 
        aDoc.PrintOut(ref missingValue,ref missingValue,ref missingValue,ref filePath,ref missingValue,ref missingValue,ref missingValue,
            ref missingValue,ref missingValue,ref missingValue,ref missingValue,ref missingValue,
            ref missingValue,ref missingValue,ref missingValue,ref missingValue,ref missingValue, ref missingValue);
 
            /*aDoc.PrintOut(ref myFalse, ref myFalse, ref range,
                ref filePath, ref missingValue, ref missingValue,
                ref items, ref copies, ref pages, ref pageType, ref myFalse,
                ref myTrue, ref missingValue, ref myFalse, ref missingValue,
                ref missingValue, ref missingValue, ref missingValue);*/
            aDoc.Close(ref missingValue, ref missingValue, ref missingValue);
            aWord.Quit(ref myFalse, ref missingValue, ref missingValue);
 
            aWord = null;
            aDoc = null;
 
        }
        catch { ...}
    }
Si qqun connait une solution (gratuite si possible) me permettant de faire cette conversion, qu'il me fasse signe

Merci a tous