Как распечатать файл pdf в цвете с помощью Adobe Reader в C# - PullRequest
0 голосов
/ 27 мая 2020

В моем приложении C# winform я автоматически распечатываю файл pdf с помощью Adobe Reader D C. PDF-файл должен быть цветным, но в настройках принтера в настройках печати установлено черно-белое изображение. Как я могу изменить это свойство и программно установить его цвет. Вот мой код для автоматической печати:

public void StartPrinting(string fullFilePathForPrintProcess, string printerName)
        {
            string printApplicationPath = FindAdobeAcrobatPath();
            const string flagNoSplashScreen = "/s";
            const string flagOpenMinimized = "/h";

            var flagPrintFileToPrinter = string.Format("/t \"{0}\" \"{1}\"", fullFilePathForPrintProcess, printerName);

            var args = string.Format("{0} {1} {2}", flagNoSplashScreen, flagOpenMinimized, flagPrintFileToPrinter);

            var startInfo = new ProcessStartInfo
                            {
                                FileName = printApplicationPath,
                                Arguments = args,
                                CreateNoWindow = true,
                                ErrorDialog = false,
                                UseShellExecute = false,
                                WindowStyle = ProcessWindowStyle.Hidden
                            };

            var process = Process.Start(startInfo);

            // Close Acrobat regardless of version
            if (process != null)
            {
                process.WaitForInputIdle();
                process.CloseMainWindow();
                process.Dispose();
            }
        }

Любая помощь приветствуется.

1 Ответ

0 голосов
/ 29 мая 2020

Думаю, это то, что вы ищете

private void MyButtonPrint_OnClick(object sender, System.EventArgs e)
{

    // Set the printer name and ensure it is valid. If not, provide a message to the user.
    printDoc.PrinterSettings.PrinterName = "\\mynetworkprinter";

    if (printDoc.PrinterSettings.IsValid) {

        // If the printer supports printing in color, then override the printer's default behavior.
        if (printDoc.PrinterSettings.SupportsColor) {

            // Set the page default's to print in color.
            printDoc.DefaultPageSettings.Color = true;
        }

        // Provide a friendly name, set the page number, and print the document.
        printDoc.DocumentName = "My Presentation";
        currentPageNumber = 1;
        printDoc.Print();
    }
    else {
        MessageBox.Show("Printer is not valid");
    }
}

Полный код можно найти по адресу

Документация Microsoft

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...