1. Declare INovaPdfOptions variable
Private mobjNovaOptios As NovaPdfOptionsClass
2. Initialize INovaPdfOptions
mobjNovaOptios = New NovaPdfOptionsClass
' initialize the NovaPdfOptions object
' if you have an application license for novaPDF SDK,
' pass both the registration name and the license key to the Initialize() function
' mobjNovaOptios.Initialize(PRINTER_NAME, "<registration name>", "<license key>");
mobjNovaOptios.Initialize(PRINTER_NAME, "", "", "")
AddSmallProfile()
AddFullProfile()
3. Set novaPDF Printer Options
Try
mobjNovaOptios.AddProfile2(SMALL_SIZE_PROFILE, PROFILE_IS_PUBLIC)
' Set some options to this profile
' disable the "Save PDF file as" prompt
mobjNovaOptios.SetOptionLong2(NovaOptions.NOVAPDF_SAVE_PROMPT, 1, SMALL_SIZE_PROFILE, PROFILE_IS_PUBLIC)
' set generated Pdf files destination folder "c:\"
mobjNovaOptios.SetOptionString2(NovaOptions.NOVAPDF_SAVE_FOLDER, "c:\", SMALL_SIZE_PROFILE, PROFILE_IS_PUBLIC)
// .....
Catch ComException As System.Runtime.InteropServices.COMException
If ((Not ComException.ErrorCode Xor NovaErrors.NV_PROFILE_EXISTS) Xor -1) = 0 Then
System.Diagnostics.Debug.WriteLine("Profile ""Small Size Profile"" exists")
Else
MessageBox.Show("Error creating Small Size Profile:" & Microsoft.VisualBasic.Chr(13) & "" & Microsoft.VisualBasic.Chr(10) & "" + ComException.Message)
System.Diagnostics.Debug.WriteLine(ComException.Message)
End If
End Try
4. Start a print job
Private Sub btnStartPrinting_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartPrinting.Click
UpdateProfileFromDialog()
mobjNovaOptios.SetActiveProfile2(CType((cmbProfiles.SelectedItem), String))
mobjNovaOptios.SetDefaultPrinter()
mobjNovaOptios.LicenseShellExecuteFile(txtFileToConvert.Text)
Dim myProcess As Process = New Process
Try
myProcess.StartInfo.FileName = txtFileToConvert.Text
myProcess.StartInfo.Verb = "Print"
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
Catch ex As Win32Exception
If ex.NativeErrorCode = ERROR_FILE_NOT_FOUND Then
Console.WriteLine(ex.Message + ". Check the path and filename")
Else
' Note that if your word processor might generate exceptions
' such as this, which are handled first.
If ex.NativeErrorCode = ERROR_ACCESS_DENIED Then
Console.WriteLine(ex.Message + ". You do not have permission to print this file.")
End If
End If
End Try
myProcess.WaitForExit(10000)
myProcess.Close()
mobjNovaOptios.RestoreDefaultPrinter()
End Sub