Sample SDK code (.cpp) for printing "Hello World" text to the novaPDF Printer from remote computer.
Hello World (network) sample is similar with Hello World sample but it can be used from network and print to novaPDF installed on a different computer. The sample requests the shared printer name in a dialog as
\\computer name\printer name
(for example if novaPDF is installed on WS1, then you should enter \\WS1\novaPDF
).Note: To be able to use the samples you must install novaPDF SDK as samples work only with it. Download it here: novaPDF SDK.
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;
}
//create one NovaPdfOptions instance
INovaPdfOptions *pNova = 0;
hr = CoCreateInstance(__uuidof(NovaPdfOptions80), NULL, CLSCTX_INPROC_SERVER, __uuidof(INovaPdfOptions80), (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 the NovaPdfOptions object to use with a printer licensed for SDK
hr = pNova->Initialize((LPCWSTR)strPrinterName, L"");
//...
}