Getting printer list on MAC OSX Topic is solved
Getting printer list on MAC OSX
How to get a list of installed printers on MAC?
Re: Getting printer list on MAC OSX
I'm not 100% sure, but i think there is no API for that in wxWidgets.
http://trac.wxwidgets.org/ticket/12879
http://trac.wxwidgets.org/ticket/12879
Use the source, Luke!
Re: Getting printer list on MAC OSX
this ticket is still in opened state.
Re: Getting printer list on MAC OSX
I know. I just posted it as an indicator that this might not be possible.
As the ticket hasn't been touched for 4 years, it probably has been forgotten. The link to the code by one of the commenters is dead, too.
As the ticket hasn't been touched for 4 years, it probably has been forgotten. The link to the code by one of the commenters is dead, too.
Use the source, Luke!
Re: Getting printer list on MAC OSX
doesnt mac use cups?
if it does then cups_dest_t and cupsGetDests should get you where you need to go
eg to get the default printer
if it does then cups_dest_t and cupsGetDests should get you where you need to go
eg to get the default printer
Code: Select all
cups_dest_t* dests;
int num_dests = cupsGetDests(&dests);
wxString retval = "";
for (int i = 0; i < num_dests; i++) {
if (dests[i].is_default) {
if (dests[i].instance) {
retval = wxString::Format("%s%s", dests[i].name, dests[i].instance);
}
else {
retval = wxString::Format("%s", dests[i].name);
}
}
}
//free memory from cups data
cupsFreeDests(num_dests, dests);
return retval;
Re: Getting printer list on MAC OSX
Thanks for a hint.
I think this code should work under Linux and MAC, since I see printer list on both OSs by following this adress http://127.0.0.1:631/printers
I downloaded cups folder with include files, but cannot figure out which lib to include into project.
Could you help me?
I think this code should work under Linux and MAC, since I see printer list on both OSs by following this adress http://127.0.0.1:631/printers
I downloaded cups folder with include files, but cannot figure out which lib to include into project.
Could you help me?
Re: Getting printer list on MAC OSX
gotcha...
/usr/lib/libcups.dylib for MAC
and
/usr/lib/x86_64-linux-gnu/libcups.so.2 for UBUNTU
the code works as I wanted
Thank you
/usr/lib/libcups.dylib for MAC
and
/usr/lib/x86_64-linux-gnu/libcups.so.2 for UBUNTU
the code works as I wanted
Thank you
Re: Getting printer list on MAC OSX
That's my code
Code: Select all
bool GetPrinterList(wxArrayString &ar, wxString &szDefaultPrinterName)
{
ar.Empty();
szDefaultPrinterName.Empty();
#ifdef __WXMSW__
DWORD dwSize, dwPrinters;
BYTE *pBuffer;
DWORD szz = 255;
WCHAR c[256];
GetDefaultPrinter(&c[0], &szz);
szDefaultPrinterName = c;
::EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 5, NULL, 0, &dwSize, &dwPrinters);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER || dwSize == 0)
return false;
pBuffer = new BYTE[dwSize];;
::EnumPrinters(PRINTER_ENUM_LOCAL, NULL, 5, pBuffer, dwSize, &dwSize, &dwPrinters);
if (dwPrinters != 0)
{
PRINTER_INFO_5 *pPrnInfo = (PRINTER_INFO_5 *)pBuffer;
for (UINT i = 0; i < dwPrinters; i++)
{
ar.Add(pPrnInfo->pPrinterName);
pPrnInfo++;
}
}
if (pBuffer)
{
delete[] pBuffer;
pBuffer = NULL;
}
return true;
#else
//#if defined( __WXOSX__) || defined( __WXGTK__)
cups_dest_t* dests;
int num_dests = cupsGetDests(&dests);
for (int i = 0; i < num_dests; i++)
{
wxString sz;
if (dests[i].instance)
sz = wxString::Format("%s%s", dests[i].name, dests[i].instance);
else
sz = wxString::Format("%s", dests[i].name);
if (dests[i].is_default)
szDefaultPrinterName = sz;
ar.Add(sz);
}
//free memory from cups data
cupsFreeDests(num_dests, dests);
if(ar.GetCount())
return true;
//do some other methods
#endif