Code Samples - Neevia docuPrinter SDK

Example 1: How to create a simple PDF file - Visual Basic Copy 

 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
   Sub HelloWorld()

       Dim DPSDK : Set DPSDK = CreateObject("docuPrinter.SDK")
       DPSDK.BackupSettings
       Dim printerFound : printerFound = False
   
       Dim objPrinter

       For Each objPrinter In Printers

        If objPrinter.DeviceName = "docuPrinter" Then
           printerFound = True
           Set Printer = objPrinter
           Exit For
        End If

       Next

       If Not printerFound Then
         MsgBox "Printer not found!!!"
         Exit Sub
       End If

       DPSDK.DocumentOutputFormat = "PDF"
       DPSDK.DocumentOutputName = "demoVB"
       DPSDK.DocumentOutputFolder = "c:\users\public\"   
 
       DPSDK.HideSaveAsWindow = true
       DPSDK.DefaultAction=1
       DPSDK.ApplySettings
 
       Printer.FontName = "Times New Roman"
       Printer.FontSize = 48
       Printer.Print "Hello from Visual Basic!!!"

       Printer.EndDoc

       Dim RVal : RVal = DPSDK.Create ' Create output document
       DPSDK.RestoreSettings
       Set DPSDK = Nothing

       If (RVal <> 0) Then 
         MsgBox "Error while creating the document!!!"
       Else
         MsgBox "Done!!!"
       End If

   End Sub