dotnet / core

.NET news, announcements, release notes, and more!
https://dot.net
MIT License
20.96k stars 4.91k forks source link

printTicket - Stapling not working #2034

Closed Darrenwcox closed 6 years ago

Darrenwcox commented 6 years ago

I am trying to get Stapling to work using a PrintTicket.

Like this: https://stackoverflow.com/questions/48450487/print-pdf-in-c-sharp-with-staples

My printer supports stapling (since I can hit the print dialog, choose staping, and it staples).

However, using this code:

 var queues = server.GetPrintQueues();
            using (var queue = queues.FirstOrDefault(x => x.FullName == printerName))
            {
                var printTicket = queue.DefaultPrintTicket;
                printTicket.Collation = Collation.Collated;
                printTicket.Stapling = Stapling.StapleTopLeft;
                queue.UserPrintTicket = printTicket;
                queue.CurrentJobSettings.CurrentPrintTicket = printTicket;
                var ret = queue.MergeAndValidatePrintTicket(queue.UserPrintTicket, printTicket);
         }

Does NOT make the "Stapling.StapleTopLeft" option work on the print ticket.

This must be a bug, and need to figure this out.

Thanks,

Darren

karelz commented 6 years ago

Do you have troubles on .NET Framework or .NET Core? (did you try both?) Do you have same problems in other environments? (different printer, different machine)

Darrenwcox commented 6 years ago

On the dot NET Framework but I would assume it would happen on the core as well.

On Wed, Oct 31, 2018, 11:56 AM Karel Zikmund notifications@github.com wrote:

Do you have troubles on .NET Framework or .NET Core? (did you try both?) Do you have same problems in other environments? (different printer, different machine)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dotnet/core/issues/2034#issuecomment-434739290, or mute the thread https://github.com/notifications/unsubscribe-auth/AqjdfVtbA_eKKYPs8I8YAV_xo--9wfbLks5uqcgzgaJpZM4YD_hu .

Darrenwcox commented 6 years ago

And also I've tried it on Windows 7 and Windows 10 but I only have the one printer that can do stapling. I assume this problem is happening other people since other people have reported it on stack overflow.

On Wed, Oct 31, 2018, 12:59 PM Darren Cox darrencox7777@gmail.com wrote:

On the dot NET Framework but I would assume it would happen on the core as well.

On Wed, Oct 31, 2018, 11:56 AM Karel Zikmund notifications@github.com wrote:

Do you have troubles on .NET Framework or .NET Core? (did you try both?) Do you have same problems in other environments? (different printer, different machine)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dotnet/core/issues/2034#issuecomment-434739290, or mute the thread https://github.com/notifications/unsubscribe-auth/AqjdfVtbA_eKKYPs8I8YAV_xo--9wfbLks5uqcgzgaJpZM4YD_hu .

karelz commented 6 years ago

We do not track .NET Framework bugs on GitHub. You can either contact Microsoft support or use VS Developer Community portal for that - see details: https://github.com/dotnet/core/blob/master/README.md#getting-help

john5000 commented 3 years ago

For anyone stumbling upon this.

I had the same problem. printTicket.Stapling = Stapling.StapleTopLeft; would not work. Worked for some printers, but not for the Canon using their Canon Generic Plus driver (the main one used on their printers). The .GetPrinterCapabilities show no staple option available. Yet from other apps you could control the stapling, such as from Word.

I found that printQueue.GetPrintQueueCapabilitiesAsXml() revealed the stapled capability. From there, updated the printing ticket XML and it worked. Basic steps were:

See: the https://docs.microsoft.com/en-us/dotnet/api/system.printing.printticket?view=net-5.0