Buy Now

novaPDF Professional
$62.44 $49.95

novaPDF Standard
$53.27 $39.95

novaPDF Lite
$24.94 $19.95

Awards & Reviews

  • 1_ico
  • 2_ico
  • 3_ico
  • 4_ico

Lockergnome feature

novaPDF is really neat

"novaPDF – Print To PDF Without Breaking The Bank. After downloading and installing the program (which takes all of one minute) you’re ready to print to a PDF. Any program that can print via the standard Windows printer interface can print to PDF (i.e. convert a file to PDF), including text, Word, Excel, […] , novaPDF will convert your files into PDF format without making your wallet cry."

Editor’s Review

This application is great

"[...] Pluses: novaPDF supports multiple profiles. This means that all your settings can be easily saved or loaded. Another great feature is the program’s ability to put bookmarks into the PDF document it creates. Drawbacks/flaws: [none] In conclusion: This application is great for generating PDF documents out of any type of printable data."

Indezine Review

Provides a good balance

"[...] novaPDF provides a good balance between price and performance -- it's a very usable option between free and highly priced PDF creators so that you can provide PDF output capabilities to a large number of users at a reasonable cost."

AC Review

Extremely easy to use

"[...]I highly recommend NovaPDF as a great and very simple way to create standard PDF documents that are fully compatible with Adobe Acrobat Reader. Nova PDF creator is an extremely easy to use and simple PDF creator"

Latest News

April 12, 2010

novaPDF 7.1 was released.

Changes in version 7.1:
  • Added visibility layers for watermarks
  • Added Document Creator option
  • Added Page Scaling options
  • Added option to remove PDF after emailing
  • Added Lithuanian language

You can download version 7 here: Download novaPDF 7.1

Stay Updated

To join, simply enter your email address below and click on Subscribe.

About Us

Softland, the company that develops novaPDF, achieved the Microsoft Certified Partner status with an ISV/Software Solutions Competency. Microsoft Certified Partner
Share
Add comment
Votes: 0
Comments: 0
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.

The VCL Converter (Delphi PDF) sample demonstrates how to convert an existing file by printing it to novaPDF Printer using the ShellExecute function. It also demonstrates how to set different options and manage profiles.

The same approach should be taken if you print using a "Print()" method from another object (like an internet browser or a report control). Just replace the ShellExecute call with the call of your Print method.

When the application starts, it creates a few profiles and makes different settings in the profiles. Then it shows a dialog from where the user can select the active profile and change its settings using the controls from the dialog. After that a document can be selected from the harddisk and printed to novaPDF Printer using the ShellExecute function call.

When using this technique to convert a file to PDF, you have to take care of the fact that ShellExecute prints to the default printer. This function returns immediately and does not wait until the print is finished (it may return before the printing is actually started). Therefore you have to set the default printer to novaPDF Printer before calling ShellExecute (using the SetDefaultPrinter method), register FileSaved message (or any other novaPDF Printer message) to be sure that the print job was started. In this message handler restore the default printer (with the RestoreDefaultPrinter method). This way you made sure that the default printer was restored and your document is printed to novaPDF Printer.


Source Code Snippets

1. Declare INovaPdfOptions variable
//declare an INovaPdfOptions member variable
private
m_novaOptions : INovaPdfOptions; 

2. Register novaPDF Printer messages
//register event messages
WM_NOVAPDF2_FILESAVED := RegisterWindowMessage(MSG_NOVAPDF2_FILESAVED);
WM_NOVAPDF2_PRINTERROR:= RegisterWindowMessage(MSG_NOVAPDF2_PRINTERROR); 

// handle event messages
public
procedure WndProc(var Message: TMessage); override;
procedure TForm1.WndProc(var Message: TMessage);
begin
if Message.Msg = WM_NOVAPDF2_FILESAVED then begin
  // ...
end else if Message.Msg = WM_NOVAPDF2_PRINTERROR then begin
  // ...
end else begin
  inherited WndProc(Message);
end;
end; 

3. Initialize INovaPdfOptions
procedure TForm1.FormCreate(Sender: TObject);
begin
// ... 

// initialize COM libraries
hr := ActiveX.CoInitialize(nil);
if FAILED(hr) then begin
  MessageDlg('Failed to initialize COM' +#13+SysErrorMessage(hr) +#13+
             SysErrorMessage(GetLastError()), mtWarning, [mbOK], 0);
end; 

//create an instance of INovaPdfOptions
m_novaOptions := nil;
hr := ActiveX.CoCreateInstance(
        CLASS_NovaPdfOptions, //CLSID_CNovaPdfSource
        nil,
        CLSCTX_INPROC_SERVER,
        IID_INovaPdfOptions,
        m_novaOptions);
if (FAILED(hr))   then begin
  MessageDlg('Failed to create novaPDF COM object',
             mtWarning, [mbOK], 0);
  exit;
end; 

//initialize NovaPdfOptions and pass printer name
//if you have an application license for novaPDF SDK,
//pass both the registration name and the license key to the Initialize2() function
//hr := m_novaOptions.Initialize2( PRINTER_NAME, '<registration name>', '<license key>');
hr := m_novaOptions.Initialize2( PRINTER_NAME, '', '', '' );
if (FAILED(hr))   then begin
  MessageDlg('Failed to initialize NovaPdfOptions',
             mtWarning, [mbOK], 0);
  exit;
end; 

// add 2 profiles in registry
CreateProfiles(); 

// load profiles from registry
LoadProfiles(); 

end; 

4. Release INovaPDFOptions 

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin 

  //... 

  //delete profiles
  hr := m_novaOptions.DeleteProfile2( SMALL_SIZE_PROFILE, PROFILE_IS_PUBLIC );
  hr := m_novaOptions.DeleteProfile2( FULL_OPT_PROFILE, PROFILE_IS_PUBLIC ); 

  // destroy m_novaOptions object
  //  - no need for this as the Delphi takes care of it automatically 

  // uninitialize COM libraries
  ActiveX.CoUninitialize(); 

  //...
end;
5. Set novaPDF Printer Options
procedure TForm1.CreateProfiles();
begin
// Add a profile called "Small size". if profile L"Small size" exists this will fail
hr := m_novaOptions.AddProfile2(SMALL_SIZE_PROFILE, PROFILE_IS_PUBLIC); 

// Set some options to this profile 

// disable the "Save PDF file as" prompt
hr := m_novaOptions.SetOptionLong2(NOVAPDF_SAVE_PROMPT,
                                   0,
                                   SMALL_SIZE_PROFILE,
                                   PROFILE_IS_PUBLIC);
// set generated Pdf files destination folder to the application path
hr := m_novaOptions.SetOptionString2(
                      NOVAPDF_SAVE_FOLDER,
                      ExtractFilePath(Application.ExeName),
                      SMALL_SIZE_PROFILE,
                      PROFILE_IS_PUBLIC);
// set output file name
hr := m_novaOptions.SetOptionString2(NOVAPDF_SAVE_FILE,
                                     'PDF Converter small size.pdf',
                                     SMALL_SIZE_PROFILE,
                                     PROFILE_IS_PUBLIC); 

//Set other options and profiles
//...
end; 

6. Start a print job 

procedure TForm1.btnStartPrintClick(Sender: TObject);
var
hExec : HINST;
begin
//... 

hr := S_OK; 

// set the active profile to be used for printing
hr := m_novaOptions.SetActiveProfile2(cbProfiles.Text, PROFILE_IS_PUBLIC); 

// register our window to receive messages from the printer
hr := m_novaOptions.RegisterEventWindow(self.Handle); 

// set novaPDF as default printer, so it will be used by ShellExecute
hr := m_novaOptions.SetDefaultPrinter(); 

//license the file to be converted with Shellexecute
hr := m_novaOptions.LicenseShellExecuteFile(efFileToConvert.Text); 

// print the document
m_bPrintJobPending := TRUE; 

hExec := ShellAPI.ShellExecute(self.handle,
                               'print',
                               PChar(efFileToConvert.Text),
                               PChar(''), PChar(''), SW_HIDE); 

if (hExec <= 32) then begin // failed to execute program
  m_bPrintJobPending := FALSE;
  hr := m_novaOptions.UnRegisterEventWindow();
  hr := m_novaOptions.RestoreDefaultPrinter();
end; 

end; 

7. Restore default printer when printing finished 

procedure TForm1.WndProc(var Message: TMessage);
begin
if Message.Msg = WM_NOVAPDF2_FILESAVED then begin 

  // restore original default printer
  hr := m_novaOptions.UnRegisterEventWindow();
  hr := m_novaOptions.RestoreDefaultPrinter();
  m_bPrintJobPending := FALSE; 

end else if Message.Msg = WM_NOVAPDF2_PRINTERROR then begin 

  case (Message.WParam) of
    ERROR_MSG_TEMP_FILE : begin
      MessageDlg('Error saving temporary file on printer server',
                 mtWarning, [mbOK], 0);
    end;
    ERROR_MSG_LIC_INFO : begin
      MessageDlg('Error reading license information',
                 mtWarning, [mbOK], 0);
    end;
    ERROR_MSG_SAVE_PDF : begin
      MessageDlg('Error saving PDF file', mtWarning, [mbOK], 0);
    end;
    ERROR_MSG_JOB_CANCELED : begin
      MessageDlg('Print job was canceled', mtWarning, [mbOK], 0);
    end;
  end;
  // restore original default printer
  hr := m_novaOptions.UnRegisterEventWindow();
  hr := m_novaOptions.RestoreDefaultPrinter();
  m_bPrintJobPending := FALSE; 

end else begin 

  inherited WndProc(Message); 

end;
end;

Add comment
Name:
Email:
* Comment:
(Use BBcode - No HTML)


Others in this Category
document [novaPDF SDK] - Are printer options related to each other? Do I need to set any option before I can set the Save Folder and Save folder options?
document VBNet Converter - SDK sample
document Java PDF writer - SDK sample
document [novaPDF SDK] - Do I have to open or activate a profile before trying to set an option for the printer driver?
document Distributing novaPDF with 32bit applications that run on Windows x64
» More articles
RSS

Legal Notices Terms of Use

Copyright Softland 2010. All rights reserved.