Code Samples - Neevia docCreator

Example 1: How to create a simple PDF file - VB.NET 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
    Private Sub prn_PrintPage(ByVal sender As System.Object, _
                              ByVal e As System.Drawing.Printing.PrintPageEventArgs)

        e.Graphics.DrawString("Hello from VB.NET", New Font("Arial", 60, FontStyle.Regular), _
                              Brushes.Blue, 100, 100)

    End Sub

    Private Sub PrintTest()
        Dim DC As Object = CreateObject("Neevia.docCreator")

        DC.setParameter("DocumentOutputFormat", "PDF")
        DC.setParameter("DocumentOutputName", "testVBNET")
        DC.setParameter("DocumentOutputFolder", "c:\users\public\")

        Dim prn As New System.Drawing.Printing.PrintDocument
        AddHandler prn.PrintPage, AddressOf prn_PrintPage
        prn.PrinterSettings.PrinterName = "Neevia docCreator"

        Dim tempFile As String = DC.getParameter("TempDir") + DC.GUID + ".ps"

        prn.PrinterSettings.PrintFileName = tempFile
        prn.PrinterSettings.PrintToFile = True

        prn.Print()

        DC.setInputDocument(tempFile)

        Dim RVal As Integer = DC.create()
        DC.fileDelete(tempFile)

        prn = Nothing
        DC = Nothing

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