C# unable to print to pdf using worksheet.PrintOut() because of the Implementation of Sensitivity Labels in Microsoft Office

ptuga 21 Reputation points
2024-03-13T00:41:44.1233333+00:00

Hello,

I have a WinForms application which have been working since today.

The company where I work in, informed us about an Implementation of Sensitivity Labels in

Microsoft Office.

This app is able to create an excel file and different sheets in this document.

The user is able also to print these tabs by the app interface with a click of a button and the

output results in a pdf file with a given name and location. No effort for the user.

The app uses C# and the command used is Worksheet.PrintOut().

What seems to be happening now is that the tabs cannot be printed out to a pdf the file the app waits indefinitely and I had to include a timeout to stop execution.

When I try to do this manually in Excel using the "Microsoft Print to PDF" printer a dialogue is now

appearing regarding the "Microsoft Information Protection".

If you manually select "Print without sensitivity labels and other metadata" giving a justification

and press continue the file is printed.

But what I wish is for this to be done as before in a transparent way without user intervention.

Not just nothing is happening but also that dialog is not presented to the user as a last resource.

2024-03-12_23h58_56

2024-03-13_00h04_34

Because I had issues in the past with Adobe Acrobat and margins issues I started to use Microsoft Print to PDF but now this is a major road block.

I am using Office version 2311 on Windows 10 Enterprise 22H2.

Please feedback.

Thank you

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
1,429 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,164 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ptuga 21 Reputation points
    2024-03-13T23:15:13.1233333+00:00

    Hi @Jiale Xue - MSFT ,

    Thank you for your answer.

    Unfortunately it falls short on one's expectations.

    This is a company lead policy and cannot be rolled back.

    What I would like to have answered is to provide a forward suggestion to find a minimal pathway solution for the problem.

    Questions like: The dialog isn't displayed when the method is executed. If it was, it would at least provide the way for the user to take action but the file would be created anyway. Why not?

    I can still print the pdf if I do it manually, so, doing in code is so much different? Why doesn't the method have the necessary arguments to specify the option?

    Also, if I print in Acrobat, I can print the document with no need to answer any question. Why?

    Any help will be welcome.

    I am not sure if my query is being understood.

    Maybe anyone can support?

    Thank you

    0 comments No comments