Table of Contents

User Information in Print Job

If you use printer management software that depends on user information, you need to consider a couple of things. Programs such as Follow Me can handle Windows print jobs depending on the user.

If you are using the direct print service, then the Windows print jobs are created in the service's user context. The user can be a Windows system or network user or a regular user. If your printer software relies on the user name, then it will not function correctly.

In situations like this, we usually recommend looking at client-print instead of service-print. With client-print, the logged-in Windows user running the browser becomes the user on the Windows print job.

PDF printer on the server

Another scenario could be a PDF printer on a server. This printer should create PDF documents and save them in locations specific to the Business Central user who created the print job.

Windows print jobs created by the print service contain the document name from the direct print queue as part of the job name. Therefore, we can try to add the Business Central user name to the document name in the print queue. For this, we have an event on the printer queue table. The event is called every time a new job is added to the printer queue.

[IntegrationEvent(False,False)]
procedure OnAfterInsertPrintJob(var DirPrtQueue: Record "ForNAV DirPrt Queue")

In a codeunit, we create the following event subscriber:

[EventSubscriber(ObjectType::Table, database::"ForNAV DirPrt Queue", 'OnAfterInsertPrintJob', '', false, false)]
local procedure OnAfterInsertPrintJob(var DirPrtQueue: Record "ForNAV DirPrt Queue")
var
    documentNameLbl: Label '[%1] %2', Comment = '%1 = user name, %2 = document name';
begin
    DirPrtQueue."Document Name" := CopyStr(StrSubstNo(documentNameLbl, UserID(), DirPrtQueue."Document Name"), 1, MaxStrLen(DirPrtQueue."Document Name"));
end;

When a new job is created, the event subscriber will add the user name in front of the document name.

User name in Business Central print queue

When the print service picks up the job and sends it to the printer, the user name is included in the job name in the printer queue.

User name in Windows print queue

Depending on the capabilities of the PDF printer, you may be able to extract and use the user name from the print job name.