PDF Reports - SDK sample

Download Sample
Download size: 125.3KB
[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.

PDF Reports Sample is an Access database with one table and one form. On the form you can set several options for the novaPDF Printer and then press a button to generate a PDF file. A report is made on the table and it is sent to novaPDF Printer. It demonstrates the basic use of the INovaPDFOptions interface. The printing job is made using the object "Application.Printer" Basically the sample creates a new profile called "Access Profile", sets the new profile as active, sets the user options from form controls, opens and prints a report, and restores original printer settings.

Source Code

Option Compare Database
Option Explicit

Private objPDF As Object

Const strIAProfile As String = "Access Profile"
Const strPDFDriver As String = "novaPDF Pro v5"
Const bIAPublicProfile As Long = 0

Private Sub cmdCreatePDF_Click()
  On Error GoTo Error_cmdCreatePDF_Click

  Dim strActiveProfile As String
  Dim strDefaultPrinter As String
  Dim nActiveProfilePublic As Long

  ' create the NovaPdfOptions object
  Set objPDF = CreateObject("novapi.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 strPDFDriver, "<registration name>", "<license key>"
  objPDF.Initialize2 strPDFDriver, "", "", ""

  ' Store the Default Printer.  * Note - Access cannot use the objPDF.SetDefaultPrinter command as it does not
  ' update Access internally fast enough.  You must use the Application.Printer command instead.

  strDefaultPrinter = Application.Printer.DeviceName

  ' Get the Active Profile
  objPDF.GetActiveProfile2 strActiveProfile, nActiveProfilePublic

  ' Add new profile
  objPDF.AddProfile2 strIAProfile, bIAPublicProfile

  With Me

'**************************************************************************************
      ' Set save options
      objPDF.SetOptionLong2 PDF_SAVE_PROMPT, !optSaveOptions, strIAProfile, bIAPublicProfile
      objPDF.SetOptionString2 PDF_SAVE_FOLDER, !txtSaveFolder, strIAProfile, bIAPublicProfile
      objPDF.SetOptionString2 PDF_SAVE_FILE, !txtFilename, strIAProfile, bIAPublicProfile
      objPDF.SetOptionLong2 PDF_SAVE_CONFLICT_STRATEGY, !cboWhenFileExists, strIAProfile, bIAPublicProfile

      ' After Save Action
      objPDF.SetOptionLong2 PDF_ACTION_OPEN_DOCUMENT, !chkOpenViewer, strIAProfile, bIAPublicProfile
      objPDF.SetOptionLong2 PDF_ACTION_USE_DEFAULT_VIEWER, !chkOpenViewer, strIAProfile, bIAPublicProfile

      ' .... other options

      ' Set the PDF print driver.
      objPDF.SetActiveProfile2 strIAProfile, bIAPublicProfile

      ' Set the Default printer.
      Set Application.Printer = Application.Printers(strPDFDriver)

      ' Run the selected report and create a PDF file.
      DoCmd.OpenReport "rptSMZipCode"

      ' Return to previous settings
      objPDF.SetActiveProfile2 strActiveProfile, nActiveProfilePublic
      objPDF.DeleteProfile2 strIAProfile, bIAPublicProfile

      ' Restore the Default Printer.
      Set Application.Printer = Application.Printers(strDefaultPrinter)
  End With

Exit_cmdCreatePDF_Click:
  Set objPDF = Nothing
  Exit Sub
Error_cmdCreatePDF_Click:
  Debug.Print Err.Number & ":" & Err.Description
  Resume Next
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: 14-August-2008
Downloads Download Now

Download, install and use novaPDF. Latest version: 5.4 build 270

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.4 released
February 11, 2008

What’s new (read more):
 » Added Copy Text/Image Watermarks dialog
 » Added "Lookup Address" option when sending emails
 » Corrected rotated and vertical texts conversion
 » Corrected conversion from WordArt, MS Word backgrounds and MS Visio drawings
 » Uninstaller deletes now the driver files

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.