TSE: multiple virtual printers visible by users

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: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
groupe pierredeplan
User
Posts: 4
Joined: Wed Apr 01, 2015 9:31 am

TSE: multiple virtual printers visible by users

Post by groupe pierredeplan »

Hello there :)

I'm changing the way to print a PDF in my software (vs ...another software) and I'm using now virtual printer.
My software runs in terminal server.

First, I'm using like this:

Code: Select all

// Global var
var
  PDFPFactory: CPXCControlEx = nil;
  PDFPrinter: CPXCPrinter = nil;

function MyPrinterName: string;
begin
     Result := 'PDF-XCHANGE_' + UserName + '_' + IntToStr( Application.Handle );
end;

procedure PDFInit;
begin
  if not Assigned( PDFPFactory ) then
    PDFPFactory := CoCPXCControlEx.Create;
  if not Assigned( PDFPrinter ) then
       begin
       prnt := PDFPFactory.Printer[ '', MyPrinterName, SPdfXTools_Key,   SPdfX_CodeDev];
       PDFPrinter:= IDispatch(prnt) as CPXCPrinter;
       Printer.Refresh;
       end;
end;

procedure PDFDone;
begin
     if not Assigned( PDFPFactory ) then Exit;
     PDFPFactory.RemoveOrphanPrinters( '', MyPrinterName);
     PDFPrinter := nil;
     PDFPFactory := nil;
     Printer.Refresh
end;

procedure PDFSetOptions;
begin
  PDFPrinter.Option['Save.File'] := MyFile;
  // ...  other options
end;
I tried 2 ways to use this:
1. Call PDFInit one time in session, call PDFSetOptions and Print Process at each print, then call PDFDone at the end of program.
2. Call PDFInit, then PDFSetOptions, then Print Process, then PDFDone, each Time User prints.

Advantage of the 1 is the speed when there are lots of print process, BUT other users see all the virtual printers of all users... not very clean
Advantage of the 2 is that the virtual printer appear only when a user prints, so list of printers on TSE is (almost) always clean.


Before, I was using (... Don't know if I can tell here), and only one virtual printer was installed on TSE visible by all user. At the moment of printing I set options in registry, in (HKEYCURRENTUSER section), then I started the print process. No Virtual extra-virtual printer visible by user, and speed was great because the only thing to do was to write in the registry before printing.

Is there a 3rd way: using virtual PDF XChange printer like I said just above ?
Is my code is the right one? (it is correct it runs perfectly with several users actually, but is it the good solution with your product ?)


Thank you in advance

Serge
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17823
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: TSE: multiple virtual printers visible by users

Post by Tracker Supp-Stefan »

Hello Serge,

Are you installing the driver with the /DRVwoPRN (Driver without Printer) parameter?
https://help.pdf-xchange.com/DEV/de ... stallation
Can you try this and option 1 you explained above?

And even option 2 should not be too slow, and the overhead for each user should still be less than a second and they will not notice the printers created in the system.

As for quoting other products - it's fine as long as it's just a comparison between them and us and not an attempt for e.g. advertising them :)

Cheers,
Stefan
groupe pierredeplan
User
Posts: 4
Joined: Wed Apr 01, 2015 9:31 am

Re: TSE: multiple virtual printers visible by users

Post by groupe pierredeplan »

Hello Stefan

No I didn't use the /DRVwoPRN option when I installed it -> I will do !

and /AutoUnload:nn seems to be an interesting option too...

Thank you for you reply! :)

Serge
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17823
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: TSE: multiple virtual printers visible by users

Post by Tracker Supp-Stefan »

:)
groupe pierredeplan
User
Posts: 4
Joined: Wed Apr 01, 2015 9:31 am

Re: TSE: multiple virtual printers visible by users

Post by groupe pierredeplan »

So :?

I tried the /DRVwoPRN option, but it's not the good solution for me.

If no driver installed, I run "PDFX5SA_sm.exe /SILENT /NOICONS /NORESTART" and now with /DRVwoPRN.
So with the new option, the new virtual printer "PDF-XChange Printer 2012" is not created in the list of printers.
This, is realized one time, after that the driver is always installed on computer.

On an other side, in my app, when I execute this line:

Code: Select all

prnt := PDFPFactory.Printer[ '', MyPrinterName, SPdfXTools_Key, SPdfX_CodeDev];
a Temporary Printer is created named by exemple "PDF-XCHANGE_Serge_123456".
-> This printer is always visible, even if I installed driver with /DRVwoPRN option.
(I checked in local, not in TSE because I can't do this now, but I guess this virtual printer is visible by all users like before)

In fact, it's not a problem for me to let the printer "PDF-XChange Printer 2012" always visible to all users even if not used, because it's only one printer and it's a visual indication that driver is installed for me.

My problem is that all printers "PDF-XCHANGE_User_UniqueNumber" created in the app of each user, are visible to all users.
So my solution actually is to create and destroy quickly while printing -> it's a big hasard if another user see a printer of another user...
But I notice that it's little slower when I print lots of document. (but it's not critical here!)

What I meaned with my 3rd way, is that with other product, only one printer was installed (like a normal printer indeed), no extra printer is created to print, option are write in registry before print.


Question: with the line code above, is it possible to use "PDF-XChange Printer 2012" for all users ?
Actually, I checked, if I write an existing name, a new printer is created with "(1)" suffix...
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17823
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: TSE: multiple virtual printers visible by users

Post by Tracker Supp-Stefan »

Hello groupe pierredeplan,

I had a chat with one of the colleagues from the Head office in Canada last night, and he confirmed that a new printer will always be created, and this can not be changed at the moment. We might add another option later, but we can not promise you at this moment if or when this will actually happen.
So it seems like you are left with the 2 options you already tried, and the one with dynamically creating and removing the printers as soon as the job finishes will leave cleaner printers list for your users.

Regards,
Stefan
groupe pierredeplan
User
Posts: 4
Joined: Wed Apr 01, 2015 9:31 am

Re: TSE: multiple virtual printers visible by users

Post by groupe pierredeplan »

Hello Stefan

Thank you for your help.
So you're right, I will continue with actual solution: create and destroy when user needs to use virtual printer.

I hope it's not a problem for Windows (TSE) to create/destroy printers lots of time all the day (logs windows, ressources, memory...?)

Bye :)

Serge
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17823
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: TSE: multiple virtual printers visible by users

Post by Tracker Supp-Stefan »

Hi Serge,

Can't tell about logs as I don't know how much you are logging, but memory and resources should not be an issue.

Regards,
Stefan
Post Reply