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
| Private Sub ImprimerPDFCreator()
Dim myPDFCreator As PDFCreator.clsPDFCreator
Dim fname As String, fi As FileInfo, DefaultPrinter As String
Dim opt As PDFCreator.clsPDFCreatorOptions
Dim Filetyp As Integer
Filetyp = 0 '0 pour le PDF
myPDFCreator = New PDFCreator.clsPDFCreator
opt = New PDFCreator.clsPDFCreatorOptions
If myPDFCreator.cStart("/NoProcessingAtStartup") = False Then
MsgBox("Impossible d'initialiser PDFCreator", vbCritical, "")
Exit Sub
End If
fi = New FileInfo("C:\chemin\LOGO.DOC")
If InStr(fi.Name, ".", CompareMethod.Text) > 1 Then
fname = Mid(fi.Name, 1, InStr(fi.Name,".", CompareMethod.Text) - 1)
Else
fname = fi.Name
End If
If Not myPDFCreator.cIsPrintable(fi.FullName) Then
MsgBox(
"File '" & fi.FullName & "' is not printable!", MsgBoxStyle.Exclamation, "")
Exit Sub
End If
opt = myPDFCreator.cOptions
opt.UseAutosave = 1
opt.UseAutosaveDirectory = 1
opt.AutosaveDirectory ="C:\chemin\"
opt.AutosaveFormat = Filetyp
opt.AutosaveFilename = fname
myPDFCreator.cOptions = opt
myPDFCreator.cSaveOptions()
myPDFCreator.cClearCache()
DefaultPrinter = myPDFCreator.cDefaultPrinter
myPDFCreator.cDefaultPrinter ="PDFCreator"
myPDFCreator.cPrintFile(fi.FullName)
myPDFCreator.cPrinterStop =False
myPDFCreator.cPrinterStop =True
myPDFCreator.cDefaultPrinter = DefaultPrinter
myPDFCreator.cClose()
myPDFCreator =Nothing
End Sub |
Partager