예제 #1
0
        static void Main(string[] args)
        {
            string strPath =
                System.AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/");

            // Instantiate Object
            APServer.Server server = new APServer.Server();

            // Path and filename of output
            server.NewDocumentName = "Server.PowerPointPrinting.pdf";
            server.OutputDirectory = strPath;

            // Start the print job
            ServerDK.Results.ServerResult result = server.BeginPrintToPDF();
            if (result.ServerStatus == ServerDK.Results.ServerStatus.Success)
            {
                // Automate PowerPoint to print a document to activePDF Server
                // NOTE: You must add the 'Microsoft PowerPoint
                // <<version number>> Object Library' COM object as a reference
                // to your .NET application to access the PowerPoint Object.
                Microsoft.Office.Interop.PowerPoint._Application oPPT =
                    new Microsoft.Office.Interop.PowerPoint.Application();
                Microsoft.Office.Interop.PowerPoint.Presentation oPRES =
                    oPPT.Presentations.Open(
                        $"{strPath}Server.PowerPoint.Input.pptx",
                        Microsoft.Office.Core.MsoTriState.msoTrue,
                        Microsoft.Office.Core.MsoTriState.msoFalse,
                        Microsoft.Office.Core.MsoTriState.msoFalse);
                Microsoft.Office.Interop.PowerPoint.PrintOptions objOptions =
                    oPRES.PrintOptions;
                objOptions.ActivePrinter     = server.NewPrinterName;
                objOptions.PrintInBackground = 0;
                oPRES.PrintOut(1, 9999, "", 1, 0);
                oPRES.Saved = Microsoft.Office.Core.MsoTriState.msoTrue;
                oPRES.Close();
                oPPT.Quit();

                // Wait(seconds) for job to complete
                result = server.EndPrintToPDF(waitTime: 30);
            }

            // Output result
            WriteResult(result);

            // Process Complete
            Console.WriteLine("Done!");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)
        {
            string strPath =
                System.AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/");

            // Instantiate Object
            APServer.Server server = new APServer.Server();

            // Path and filename of output
            server.NewDocumentName = "Server.ExcelPrinting.pdf";
            server.OutputDirectory = strPath;

            // Start the print job
            ServerDK.Results.ServerResult result = server.BeginPrintToPDF();
            if (result.ServerStatus == ServerDK.Results.ServerStatus.Success)
            {
                // Automate Excel to print a document to activePDF Server
                // NOTE: You must add a reference to the
                // Microsoft.Office.Interop.Excel library found in the
                // reference manager under Assemblies -> Extensions
                Microsoft.Office.Interop.Excel._Application oXLS =
                    new Microsoft.Office.Interop.Excel.Application();
                oXLS.DisplayAlerts = false;
                oXLS.Visible       = false;
                object m = System.Type.Missing;
                Microsoft.Office.Interop.Excel._Workbook oWB =
                    oXLS.Workbooks.Open(
                        $"{strPath}Server.Excel.Input.xlsx", m, true, m, m, m,
                        true, m, m, false, false, m, false);
                oWB.Activate();
                oWB.PrintOut(1, 999, 1, false, server.NewPrinterName, false, false);
                oWB.Close(0);
                oXLS.Quit();

                // Wait(seconds) for job to complete
                result = server.EndPrintToPDF(waitTime: 30);
            }

            // Output result
            WriteResult(result);

            // Process Complete
            Console.WriteLine("Done!");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            string strPath =
                System.AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/");

            // Instantiate Object
            APServer.Server server = new APServer.Server();

            // Path and filename of output
            server.NewDocumentName = "Server.WordPrinting.pdf";
            server.OutputDirectory = strPath;

            // Start the print job
            ServerDK.Results.ServerResult result = server.BeginPrintToPDF();
            if (result.ServerStatus == ServerDK.Results.ServerStatus.Success)
            {
                // Automate Word to print a document to Server
                // NOTE: You must add the 'Microsoft.Office.Interop.Word'
                // reference
                Microsoft.Office.Interop.Word._Application oWORD =
                    new Microsoft.Office.Interop.Word.Application();
                oWORD.ActivePrinter = server.NewPrinterName;
                oWORD.DisplayAlerts =
                    Microsoft.Office.Interop.Word.WdAlertLevel.wdAlertsNone;
                oWORD.Visible = false;
                Microsoft.Office.Interop.Word.Document oDOC =
                    oWORD.Documents.Open($"{strPath}Server.Word.Input.doc");
                oDOC.Activate();
                oWORD.PrintOut();
                oWORD.Documents.Close();
                oWORD.Quit();

                // Wait(seconds) for job to complete
                result = server.EndPrintToPDF(waitTime: 30);
            }

            // Output result
            WriteResult(result);

            // Process Complete
            Console.WriteLine("Done!");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
예제 #4
0
        static void Main(string[] args)
        {
            string strPath =
                System.AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/");

            // Instantiate Object
            APServer.Server server = new APServer.Server();

            // Path and filename of output
            server.NewDocumentName = "Server.PrintToPDF.pdf";
            server.OutputDirectory = strPath;

            // Start the print job
            ServerDK.Results.ServerResult result = server.BeginPrintToPDF();
            if (result.ServerStatus == ServerDK.Results.ServerStatus.Success)
            {
                // Here is where you can print to ActivePDF Server to create a
                // PDF from any print job, set your application to print to a
                //static activePDF Server printer or call server.NewPrinterName
                // to dynamically create a new printer on the fly. This example
                // simply calls server.TestPrintToPDF for testing purposes
                result = server.TestPrintToPDF(sampleText: "Hello World!");
                if (result.ServerStatus ==
                    ServerDK.Results.ServerStatus.Success)
                {
                    // Wait(seconds) for job to complete
                    result = server.EndPrintToPDF(waitTime: 30);
                }
            }

            // Output result
            WriteResult(result);

            // Process Complete
            Console.WriteLine("Done!");
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }