Temporary printer life span

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Stefan - PDF-XChange

guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Temporary printer life span

Post by guy.marom »

Hello,

I can't seem to understand when the temporary printer is deleted. The documentation says that it only exists for one print job but that is incorrect. I wrote an application that creates a temp printer, configures it, sends a print job, configures it again, sends another job etc.
However, when I tried creating a printer before each job, an auto incrementing number was added to the name so I had Printer, PRinter 1, Printer 2 and so on.
I would prefer not having to create a new virtual printer for each job since it takes 1-3 seconds and my app must perform better than that.
Please elaborate on this topic.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3603
Joined: Thu Jul 08, 2004 10:36 pm

Re: Temporary printer life span

Post by Ivan - Tracker Software »

Printer is created when you call Printer property of CPXCControlEx, and is removed when you release interface of this printer.
PDF-XChange Co Ltd. (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.
guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Re: Temporary printer life span

Post by guy.marom »

Ivan - Tracker Software wrote:Printer is created when you call Printer property of CPXCControlEx, and is removed when you release interface of this printer.
By removed, do you mean calling the function RemoveOrphanPrinters from the PXCComLib.CPXCControlEx object? The object PXCComLib.CPXCPrinter doesn't have any function that I see that can "remove" it.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3603
Joined: Thu Jul 08, 2004 10:36 pm

Re: Temporary printer life span

Post by Ivan - Tracker Software »

No, you don't need to call this function.

Sample in C++ (Using CComPtr<>):

// creating the printer
pPrinter = pFactory->Printer[L"", L"My PDF-XChange", L"<REG KEY HERE>", L"<DEV CODE HERE>"];
DispEventAdvise(pPrinter); // this line required to catch events from printer

...
// removing printer
DispEventUnadvise(pPrinter); // detaching event handlers
pPrinter.Release(); // releasing printer (now temporary printer will be deleted).

/// On VB
Dim PDFPFactory As New PXCComLib.CPXCControlEx
Dim WithEvents PDFPrinter As PXCComLib.CPXCPrinter

Set PDFPrinter = PDFPFactory.Printer("", "My PDF-XChange", "<REG CODE>", "<DEV CODE>")
...
; Releasing printer - temporary printer will be deleted
Set PDFPrinter = Nothing


HTH
PDF-XChange Co Ltd. (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.
guy.marom
User
Posts: 98
Joined: Tue Feb 17, 2009 12:08 pm

Re: Temporary printer life span

Post by guy.marom »

It's not working, I'm using VB.NET:

Dim f As New PXCComLib.CPXCControlEx()
Dim p As PXCComLib.CPXCPrinter = DirectCast(f.Printer("", "MyPrinter", "", ""), PXCComLib.CPXCPrinter)
p = Nothing

It is my understanding that assigning Nothing to an object doesn't release it but simply allows its memory to be freed by the garbage collector. However calling RemoveOrphanPrinters does work. Is there any reason why I shouldn't use it?