PDF-XChange - Tracker PDF Viewer - TIFF-XChange - Image-XChange - XMF-XChange - Raster-XChange - Support

Moderators: TrackerSupp-Daniel, Tracker Support, Chris - Tracker Supp, Vasyl-Tracker Dev Team, Sean - Tracker, Tracker Supp-Stefan

 
steve.thresher
User
Topic Author
Posts: 65
Joined: Wed Aug 26, 2009 8:42 am

Virtual Printers Left Behind

Wed Aug 01, 2018 8:35 am

Can you offer any suggestions as to why virtual printers are persisting after a print job has been completed and even after a server has been rebooted?

Multiple PDF-XChange V6 printers.jpg
 
User avatar
Will - Tracker Supp
Site Admin
Posts: 6154
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Virtual Printers Left Behind

Wed Aug 01, 2018 8:51 am

Hi Steve,

Thanks for the post - Are you using an SDK to create these printers and serve them to users, or have you virtualized the end user printers?

Thanks,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
 
steve.thresher
User
Topic Author
Posts: 65
Joined: Wed Aug 26, 2009 8:42 am

Re: Virtual Printers Left Behind

Mon Aug 06, 2018 10:11 am

Here's a stripped down version of the code we're using:

void print_pdf()
{
   //Sleep(20000);

   PXC6::IPXCControlExPtr   pFactory6;

   try
   {
      CLSID clsid;
      if (SUCCEEDED(CLSIDFromProgID(L"PXCComLib6.CPXCControlEx",&clsid)))
         pFactory6 = PXC6::IPXCControlExPtr(__uuidof(PXC6::CPXCControlEx));
   }
   catch (_com_error &e)
   {
      CString str;
      str.Format(L"COM exception %d generated when creating PDF-XChange factory",e.Error());
      AfxMessageBox(str);

      return;
   }
   catch (...)
   {
      return;
   }

   PXC6::IPXCPrinterPtr pPrinter6;

   try
   {
      pPrinter6 = pFactory6->Printer[L"",
         L"PDF-XChange Standard V6",

         // Licence details hidden as requested by Tracker support
         L"",
         L""];
   }
   catch (_com_error &e)
   {
      CString str;
      str.Format(L"COM exception %d generated when creating PDF-XChange printer",e.Error());

      AfxMessageBox(str);

      pFactory6.Release();
      return;
   }
   catch (...)
   {
      AfxMessageBox(L"Exception generated when creating PDF-XChange 6 printer");
      pFactory6.Release();
      return;
   }

   pPrinter6->ResetDefaults();
   pPrinter6->Option[L"Save.SaveType"] = L"Save";
   pPrinter6->Option[L"Save.ShowSaveDialog"] = L"No";

   TCHAR filespec[100];
   time_t now_time_t = time(0);
   tm now_tm;
   localtime_s(&now_tm,&now_time_t);
   wcsftime(filespec,sizeof(filespec),TEXT("E:\\TEMP\\PrintPDF-%Y%m%d_%H%M%S"),&now_tm);

   pPrinter6->Option[L"Save.File"] = filespec;// L"E:\\Temp\\PrintPDF.PDF";

   pPrinter6->Option[L"Save.WhenExists"] = L"Overwrite";
   pPrinter6->Option[L"Save.RunApp"] = FALSE;
   pPrinter6->Option[L"Overlay.Enabled"] = FALSE;
   pPrinter6->Option[L"Compression.Graphics"] = TRUE;
   pPrinter6->Option[L"Compression.Text"] = TRUE;
   pPrinter6->Option[L"Fonts.EmbedAll"] = FALSE;
   pPrinter6->Option[L"Saver.ShowProgress"] = FALSE;

   pPrinter6->ApplyOptions(0);

   HDC hDC;

   // Create the HDC for the printer
   if ((hDC = CreateDC(TEXT("WINSPOOL"),pPrinter6->GetName(),NULL,NULL)) != NULL)
   {
      // The StartDoc function starts the print job
      DOCINFO di = {sizeof(DOCINFO)};
      di.lpszDocName = TEXT("Print Job");

      if (StartDoc(hDC,&di) > 0)
      {
         // The StartPage function prepares the printer driver to accept data
         if (StartPage(hDC) > 0)
         {
            TCHAR szString[100] = {};

            wcsftime(szString,sizeof(filespec),TEXT("Printing from a service %d/%m/%Y %H:%M:%S"),&now_tm);
            TextOut(hDC,0,0,szString,lstrlen(szString));

            EndPage(hDC);
         }

         EndDoc(hDC);
      }

      //  Delete the HDC
      DeleteDC(hDC);
   }

   if (pPrinter6)
      pPrinter6.Release();

   if (pFactory6)
      pFactory6.Release();
}



Does this give you what you need to know?
 
steve.thresher
User
Topic Author
Posts: 65
Joined: Wed Aug 26, 2009 8:42 am

Re: Virtual Printers Left Behind

Tue Aug 07, 2018 9:15 am

Any thoughts on this one?
 
User avatar
Will - Tracker Supp
Site Admin
Posts: 6154
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Virtual Printers Left Behind

Tue Aug 07, 2018 9:27 am

Hi Steve,

Thanks for posting that and sorry for the response - I can't personally help in anyway here so I've forwarded it to the development team. I believe that the specific Dev needed is in the Canadian office, so it'll be a few hours at least before we hear back.

Thanks,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
 
Ivan - Tracker Software
Site Admin
Posts: 3511
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Virtual Printers Left Behind

Tue Aug 07, 2018 5:06 pm

Please add
pFactory6->RemoveOrphanPrinters(L"", L"PDF-XChange Standard V6");


before call to pPrinter6 = pFactory6->Printer.

HTH
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
 
steve.thresher
User
Topic Author
Posts: 65
Joined: Wed Aug 26, 2009 8:42 am

Re: Virtual Printers Left Behind

Wed Aug 08, 2018 1:46 pm

Hi Ivan,

Thanks for the response. I've been back to the source to add the suggested call to find the following commented out code:

// this is in the sample code but if you do this while other sessions are printing, you can remove their printers!
// if (m_pFactory6 != NULL)
// m_pFactory6->RemoveOrphanPrinters(L"", L"");

Our application can be run concurrently by multiple users on a server with remote desktop services. How does the RemoveOrphanPrinters() function determine that a printer is genuinely orphaned and not in use by another user?

Thanks,
Steve.
 
steve.thresher
User
Topic Author
Posts: 65
Joined: Wed Aug 26, 2009 8:42 am

Re: Virtual Printers Left Behind

Wed Aug 08, 2018 1:48 pm

I've just searched the forums for RemoveOrphanedPrinters and found the following post that was created by my predecessor:

viewtopic.php?f=43&t=26825&p=104023&hilit=RemoveOrphanedPrinters#p104023

It would appear the last fix to RemoveOrphanedPrinters was years before this issue was reported.

"version 4.0.157 release - 20-02-2009"
"A reported error or bug was fixed Resolved some issues with removing orphaned printers via SDK."
 
steve.thresher
User
Topic Author
Posts: 65
Joined: Wed Aug 26, 2009 8:42 am

Re: Virtual Printers Left Behind

Mon Aug 13, 2018 6:05 am

Could someone please give me an update on this issue?
 
steve.thresher
User
Topic Author
Posts: 65
Joined: Wed Aug 26, 2009 8:42 am

Re: Virtual Printers Left Behind

Thu Aug 16, 2018 9:08 am

Could someone please comment on whether this is still a known problem or if a fix has been put in place with newer versions of the product?
 
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 12737
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Virtual Printers Left Behind

Thu Aug 16, 2018 9:13 am

Hello Steve,

Apologies for the delay here!
I did pass this topic to our devs asking for their comments and advise but have unfortunately not heard back yet. I have now nudged them a second time, and expect a reply within 24 hours.

We will post here as soon as there are any further news.

Regards,
Stefan
 
Ivan - Tracker Software
Site Admin
Posts: 3511
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Virtual Printers Left Behind

Thu Aug 16, 2018 5:08 pm

Printers are left behind because at the moment printer is trying to be removed when the instance of IPXCControlEx released, but if the printer is busy at this moment it cannot be removed and will be left.
We are working on a better mechanism for automatically removing orphaned printers, and hope it will be available in one of the nearest builds of V7.

In the version you have, the best case is to wait while document will be saved. You can do that handling printer's events, or using
IPXCPrinter::WaitForPrintEvent(event_DocumentSaved, 5000);
(5000 means "wait up to 5000ms").

HTH
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.

Who is online

Users browsing this forum: No registered users and 1 guest