Code Samples - Neevia docCreator

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
   Dim DC: Set DC = CreateObject("Neevia.docCreator")

   Dim RVal: RVal = DC.startPrinting
   If (RVal <> 0) Then
      MsgBox "Error while calling StartPrinting method!!!"
      Exit Sub
   End If

   Dim printerFound: printerFound = False

   Dim objPrinter
   For Each objPrinter In Printers
     If objPrinter.DeviceName = DC.NewPrinterName Then
        printerFound = True
        Set Printer = objPrinter
        Exit For
     End If
   Next

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

   DC.setParameter "DocumentOutputFormat", "PDF"
   DC.setParameter "DocumentOutputName", "testVB"
   DC.setParameter "DocumentOutputFolder", "c:\users\public\"

   Printer.FontName = "Times New Roman"
   Printer.FontSize = 48
   Printer.Print "Hello from Visual Basic!!!"
   Printer.EndDoc

   RVal = DC.Create ' Create output document
   If (RVal <> 0) Then MsgBox "Error while creating document!!!"

   RVal = DC.stopPrinting
   Set DC = Nothing

   If (RVal <> 0) Then
     MsgBox "Error while calling StopPrinting method!!!"
   Else
     MsgBox "Done!!!"
   End If