Hello World - SDK sample

Download Sample
Download size: 43.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 (network) sample is similar with Hello World sample but it adds network functionality:
  • it requests the shared printer name in a dialog as "\\computer name\printer name" (for example if novaPDF Pro is installed on WS1, then you should enter "\\WS1\novaPDF Pro v3")
  • it automatically registers novapi4.dll if not registered. novapi4.dll must be in the same folder with the HelloWorld (network).exe file.

You can share the folder containing HelloWorld (network).exe and novapi4.dll on your network and run the executable from any other computer in the network, with no need to install anything else. It will generate a "HelloWorldNet.pdf" file in the same folder.

Source Code snippets (in addition to Hello World source code)

{
//...
//initialize COM
hr = CoInitialize(NULL);
if (FAILED (hr))
{
  MessageBoxW(NULL, L"Failed to initialize COM", L"novaPDF", MB_OK);
  return hr;
} 

// register the novapi2.dll COM module found in this executable's directory
hr = RegisterNovaCOM(TRUE); 

//create one NovaPdfOptions instance
INovaPdfOptions *pNova = 0;
hr = CoCreateInstance(__uuidof(NovaPdfOptions), NULL, CLSCTX_INPROC_SERVER, __uuidof(INovaPdfOptions), (LPVOID*) &pNova);
if (FAILED(hr))
{
  MessageBoxW(NULL, L"Failed to create novaPDF COM object", L"novaPDF", MB_OK);
  return hr;
}
DWORD dwSize = 256;
WCHAR strWorkStation[256]; 

//find out computer name
GetComputerNameW(strWorkStation, &dwSize); 

PrinterNameDlg dlg;
//construct printer name as "\\computer name\printer name"
dlg.m_strPrinterName.Format(L"\\\\%s\\%s", strWorkStation, PRINTER_NAME); 

//get printer name from user
if (IDCANCEL == dlg.DoModal())
{
  pNova->Release();
  CoUninitialize();
  return hr;
}
CString strPrinterName = dlg.m_strPrinterName; 

//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 Initialize() function
// hr = pNova->Initialize((LPCWSTR)strPrinterName, L"<registration name>", L"<license key>");
hr = pNova->Initialize((LPCWSTR)strPrinterName, L"", L"", L"");
//...
} 

//Register novaPDF COM from novapi2.dll
//novapi2.dll should be in the same folder with the application
HRESULT RegisterNovaCOM(BOOL bRegister = TRUE)
{
HRESULT hr = E_FAIL;
WCHAR szFileName[_MAX_PATH] = L""; 

//find out application path and name
DWORD dwRes = GetModuleFileNameW(NULL, szFileName, _MAX_PATH); 

if (dwRes > 0 && dwRes < _MAX_PATH)
{
  WCHAR szDir[_MAX_PATH], szDrive[_MAX_DRIVE]; 

  //get application path
  _wsplitpath(szFileName, szDrive, szDir, NULL, NULL);
  wcscpy(szFileName, szDrive);
  wcscat(szFileName, szDir);
}

//add COM dll name
wcscat(szFileName, L"novapi5.dll"); 

//load COM dll
HMODULE hNova = LoadLibraryW(szFileName); 

typedef HRESULT (STDAPICALLTYPE *DllRegisterServerFunction)(void);
DllRegisterServerFunction fun = NULL;

if (hNova)
{
  if (bRegister)
  {
    //get the address of DllRegisterServer function
    fun = (DllRegisterServerFunction) GetProcAddress(hNova, "DllRegisterServer");
  }
  else
  {
    //get the address of DllUnregisterServer function
    fun = (DllRegisterServerFunction) GetProcAddress(hNova, "DllUnregisterServer");
  }
  if (fun)
  {
    // call DllRegisterServer (or DllUnregisterServer)
    hr = fun();
  }
}
return hr;
}

© 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.