Beispiel #1
0
        static void Main(string[] args)
        {
            string strPath = System.AppDomain.CurrentDomain.BaseDirectory;

            // Starting with Toolkit version 10 native DLLs are no longer
            // copied to the system folder. The Toolkit constructor must
            // be called with the path to the native DLLs or place them
            // in your applications working directory. This example
            // assumes they are located in the default installation folder.
            // (Use x86 in the path for 32b applications)
            string toolkitPath = $@"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)}\ActivePDF\Toolkit Ultimate\bin\x64";

            // Instantiate Object
            using (APToolkitNET.Toolkit toolkit = new APToolkitNET.Toolkit(toolkitPath))
            {
                // Get the Spooler object from Toolkit
                APToolkitNET.Spooler spooler = toolkit.GetSpooler();

                // Open the input PDF
                int result = toolkit.OpenInputFile(InputFileName: $"{strPath}Toolkit.Input.pdf");
                if (result == 0)
                {
                    // Set the duplex mode, only valid if supported by the
                    // printer.
                    spooler.DuplexMode = APToolkitNET.DuplexMode.Vertical;

                    // Set the printer name
                    spooler.PrinterName = @"\\ap-dc-02\Ops - Brother HL-6180DW";

                    // Set the number of copies to print
                    spooler.Copies = 2;

                    result = spooler.PrintFile();
                    if (result != 0)
                    {
                        WriteResult($"Error printing PDF: {result}", toolkit);
                        return;
                    }

                    // Close the new file to complete PDF creation
                    toolkit.CloseInputFile();
                }
                else
                {
                    WriteResult($"Error opening input file: {result.ToString()}", toolkit);
                    return;
                }
            }

            // Process Complete
            WriteResult("Success!");
        }