Bonjour à tous,
je souhaiterais via vb.net imprimer des documents au format pdf en utilisant
pdf creator. Je me suis donc inspiré du bout de code se trouvant dans le
dossier d'installation de pdf creator mais ca ne fonctionne pas. lorsque je
lance le programme, il ouvre le fichier word que je veux imprimer, le met dans
le spool, mais il ne l'imprime pas. J'ai fouillé dans ce bout de code mais je ne
vois pas le bug. Pouvez vous m'aider à debugger svp?
ci dessous mon code:
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
53
54
55
56
57
58
59
60
61
62
63
64 Imports System.IO Public Class Form1 Inherits System.Windows.Forms.Form Private WithEvents _PDFCreator As PDFCreator.clsPDFCreator Private pErr As PDFCreator.clsPDFCreatorError Private ReadyState As Boolean Private Const maxTime As Long = 20 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load pErr = New PDFCreator.clsPDFCreatorError _PDFCreator = New PDFCreator.clsPDFCreator With _PDFCreator If .cStart("/NoProcessingAtStartup") = False Then If .cStart("/NoProcessingAtStartup", True) = False Then MsgBox("Le traitement ne peut pas se faire actuellement") Exit Sub End If MsgBox("Une instance de PDFCreator existe déjà, il faut le fermer!") .cVisible = True End If End With End Sub Private Sub PrintIt(ByVal Filetyp As Long) Dim DefaultPrinter As String Dim opt As PDFCreator.clsPDFCreatorOptions opt = _PDFCreator.cOptions With opt .UseAutosave = 1 .UseAutosaveDirectory = 1 .AutosaveDirectory = "D:\MesPdf" .AutosaveFormat = Filetyp opt.AutosaveFilename = "Toto3" End With With _PDFCreator .cOptions = opt .cClearCache() DefaultPrinter = .cDefaultPrinter .cDefaultPrinter = "PDFCreator" .cPrintFile("D:\MesPdf\Didier.doc") ReadyState = False .cPrinterStop = False End With _PDFCreator.cPrinterStop = True _PDFCreator.cDefaultPrinter = DefaultPrinter opt = Nothing End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PrintIt(0) End Sub Private Sub PDFCreator_Ready() Handles _PDFCreator.eReady 'ToolStripStatusLabel1.Text = "Status: """ & _PDFCreator.cOutputFilename & """ was created!" _PDFCreator.cPrinterStop = True ReadyState = True End Sub Private Sub _PDFCreator_eError() Handles _PDFCreator.eError pErr = _PDFCreator.cError End Sub End Class
Partager