Hello World Visual Basic - SDK sample

Download Sample
Download size: 36.1KB
[Format: ZIP]
Note: To be able to use the samples you must install novaPDF SDK as samples work only with it. Download it here: nova PDF SDK.

Hello World VB sample is a simple Windows console application that prints one page with the "novaPDF says Hello World from VB" text to the novaPDF Printer.

It demonstrates the basic use of the INovaPDFOptions interface. The printing job is made with calls to the global Printer object defined by VB. It generates a "HelloWorld.pdf" file and opens it in the default PDF viewer.

Notice
If you print an existing document using "ShellExecute()" function or you want to handle printing events, you should check the VB Converter sample instead.


Source Code

' the novapiLib package must be added as a COM reference
Const PRINTER_NAME As String = "novaPDF Pro v5"
Const PROFILE_IS_PUBLIC As Long = 0 

' The main entry point for the application.
Public Sub Main()
  On Error GoTo ErrorHandler: 

  ' create the NovaPdfOptions object
  Dim pNova As New NovaPdfOptions 

  ' 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
  ' pNova.Initialize2 PRINTER_NAME, "<registration name>", "<license key>"
  pNova.Initialize2 PRINTER_NAME, "", "", ""
  ' get the active profile ...
  Dim activeProfile As String
  Dim bPublicProfile As Long 

  pNova.GetActiveProfile2 activeProfile, bPublicProfile
' and make a copy of it
  On Error Resume Next
  pNova.CopyProfile2 activeProfile, "Test VB", PROFILE_IS_PUBLIC
  If Err.Number <> 0 Then
      ' ignore profile exists error
      If NV_PROFILE_EXISTS = Err.Number Then
          Debug.Print "Profile Test VB already exists"
      Else
          Return
      End If
  End If

  On Error GoTo ErrorHandler:
  ' set the copy profile as active profile ...
  pNova.SetActiveProfile2 "Test VB", PROFILE_IS_PUBLIC
  ' and set some options
  pNova.SetOptionString2 NOVAPDF_INFO_SUBJECT, "VB Hello document", "", PROFILE_IS_PUBLIC 

  ' Print a test page
  Dim myPrinter As Printer 

  For Each myPrinter In Printers
      If myPrinter.DeviceName = PRINTER_NAME Then
          Set Printer = myPrinter
          Exit For
      End If
  Next 

  Printer.FontName = "Arial"
  Printer.FontSize = 16
  Printer.CurrentX = 20
  Printer.CurrentY = 20 

  Printer.Print "novaPDF says Hello World from VB"
  Printer.EndDoc 

  ' Return to previous settings
  pNova.SetActiveProfile2 activeProfile, bPublicProfile
  pNova.DeleteProfile2 "Test VB", PROFILE_IS_PUBLIC
  Exit Sub
ErrorHandler:
  Debug.Print Err.Number & ":" & Err.Description
End Sub

© 2002-2008 Softland. All Rights Reserved.
PDF Creator novaPDF
Create PDF for your paperless office
home Home   contact usContact us   partnershipsPartnerships   bookmarkBookmark   Site updated: 8-October-2008
Downloads Download Now

Download, install and use novaPDF. Latest version: 5.5 build 276

Download PDF creator
promotionsSpecial Offers

Current discounts:
- up to 25% for Desktop Editions
- up to 25% for Server Editions
- 20% Academic Discount
- up to 16% for Developer Tools

buyBuy Now
Professional edition $39.95
(Save $10)
Standard edition $29.95
(Save $10)
Lite edition $19.95
(Save $5)
Buy Now
newsLatest News

novaPDF 5.5 released
August 28, 2008

What’s new (read more):
 » Added Import/Export profiles option
 » Added external function exit code to cancel print job in novaPDF OEM
 » Added "/RegisterWin32COM" install parameter for silent installers
 » Added "/DoNotAskReason" command line parameter for silent uninstalling
 » Added new large printing forms (A0)
 » Added Norwegian and Turkish interface languages

sdkDeveloper Tools

novaPDF SDK is a software development toolkit that can be used by software developers and programmers to add the ability to create PDF files in their applications.
novaPDF OEM is a PDF solution that programmers can use to generate PDF files that will be post-processed by their applications. […]

Reviews & User QuotesPDF Creator Reviews
"novaPDF is a really neat tool. Basically, it’s a PDF printer driver that prints to a PDF file instead of paper.
See more reviews about nova PDF
[…] novaPDF is a great product that works without forcing the user to configure anything. The convenience alone is worth the money." […]
Jason Pullara, Editor
Currently supported languagesLanguages

News:
- Norwegian language added.

Help us translate novaPDF and we will give you licenses for novaPDF Professional and mention you on the Languages page. […]

awardsAwards

novaPDF received the Editor’s Pick from Soft32, a major download site:

PDF creator reviews

See the Awards page for more ratings.

NewsletterKnowledgebase articles

Latest articles on how to:
 » Create PDF files
 » Convert JPG to PDF
 » Convert Powerpoint to PDF
 » Convert Publisher to PDF
 » Convert web pages to PDF
Full article list in the knowledgebase.