In my project, I need to prohibit printing to anything other than a physical printer. The output cannot be sent to FAX, Document Writer XPS, or any PDF file writer. Is there any way to determine this by some properties in code and prohibit all destinations that are not actual physical printers? I know I can search for printer names and remove them, but that is obviously not realistic.
My strategy so far is to make my own Printer dialog, which I have working fine so far x-plat, but this problem is not solved.
On Mac, print to PDF is a system function so there is no need for users to install a “PDF Printer” although I guess some user might be able to do that on Mac?
Yes but as I mentioned, it’s not realistic. That’s way too weak of a barrier, and in many cases would be no barrier at all.
If I had access to a mythical database of all physical printer names, which did not include any Print to Document utilities or FAX machines, then I could check the printer name against this database and remove devices with names not in the database.
Such a database doesn’t exist, right?
Even if it did, checking a name property means any user could just change the name property and bypass the system.
I need a way to access some property or properties of the destination device in code, which the user cannot change, which tells me what this device is: printer, fax, or document file.
I thought so too, but I checked properties of a couple of different PDF printer utilities on Windows with my HP printer and could not see any differences.
On Mac, this never gives any opportunity to print to PDF as per the regular Printer dialog :
[code] Dim settings As String
Dim pageSetup As PrinterSetup
pageSetup = New PrinterSetup
If pageSetup.PageSetupDialog Then
settings = pageSetup.SetupString
End If
Dim g As Graphics
g = OpenPrinter(pageSetup)
g.DrawString “Hello World”, 100, 100[/code]
perhaps this link would offer some insight on how to distinguish between a physical and a virtual printer.
You will have to see whether this solution is portable to Xojo, and whether it works with all virtual printers, including the new Microsoft Print to PDF available with Windows 10.
Thank you. On Mac, unless there are 3rd party “PDF Printers” that can be installed (I don’t know of any) then I have the problem solved on Mac.
I’m asking 2 questions really:
can a “PDF printer” be installed on Mac that will appear in the physical printer list? If so then I have the same problem on Mac that I have on Windows.
how can I filter out all non-physical printers on Windows?
Please read my original post as I tried to explain there what I need.
Okay. The files are encrypted and cannot be saved to a viewable file, period. They can only be printed to paper. Printing these files to paper is the only purpose of this app, which uses passwords and online database to prohibit access to these files to anyone but licensed users. Each time a user wants to print, they open this app, and the printing action is recorded in the database. Each license gives each user a limited number of printings. If they are able to print to a file, that bypasses the whole system.
The encrypted files also cannot be viewed on the screen, or the user would easily be able to take screenshots and create files from them.
Obviously, the user can scan in a printed document and to make a file from it, but that takes longer, the file is not vector so is obviously scanned, and users are more likely to think twice about doing that.
The security measure is intended to prohibit all of the lazy ways that files could be made from these documents.
That’s a good idea, but unless I have the mythical database, I think it also means the submitted printer would need to be checked manually on reception. This will be a high volume system, so that’s not practical. I really need it all to be automatic.
Is there really no way (on Windows, but possibly also needed on Mac) to find out if the print destination is going to a file?
… I suppose on each print, a notice could say that any electronic file print destination is prohibited, and inform the user that the print destination information is sent to the online database, that violators will be prosecuted with fines and possible imprisonment
can a “PDF printer” be installed on Mac that will appear in the physical printer list? If so then I have the same problem on Mac that I have on Windows.
how can I filter out all non-physical printers on Windows?[/quote]
Devising a software printer is as possible on Mac as it is on Windows. Simply, as it has been built in for quite a while, it is improbable. I could not find any with a quick search on the Internet.
To discriminate virtual and physical printer may simply not be possible. There are many layers in the printing process, and the app is very far from the hardware.
I tried to look at the register, but there is no way to distinguish between virtual, network and physically attached printers. Seems to me you are in to look at the name of the printer, and eliminate any name with PDF and XPS in it for a start.
The list of printer exists in Windows, BTW. You get it when selecting a driver for a new printer which is not recognized right away. Then you get a list of manufacturer and for each a long series of printer names. I got that not long ago when I added a shared printer attached to the Mac on the network.
Ah, I had missed your response earlier. I noticed on that page someone says that the PRINTER_INFO_2 structure will return “FILE” as the Port Name in the structure, but this isn’t true. There may some other clue on that page. Thank you for the link.