Exemplo n.º 1
0
        static void Main(string[] args)
        {
            // Convert PDF file to RTF file. Works only in Office 2013 and higher.

            // If you are looking for solution without MS Office
            // Please take a look at our PDF Focus .Net: https://www.sautinsoft.com/products/pdf-focus/index.php

            SautinSoft.UseOffice u = new SautinSoft.UseOffice();

            string inpFile = Path.GetFullPath(@"..\..\..\..\..\Testing files\example.pdf");
            string outFile = Path.GetFullPath("Result.rtf");

            // Prepare UseOffice .Net, loads MS Word in memory
            if (u.InitWord() != 0)
            {
                Console.WriteLine("Error: Can't load MS Word in memory!");
                Console.WriteLine("Please contact SautinSoft's support Team: [email protected].");
                Console.ReadLine();
            }

            // Check MS Office version
            if (u.OfficeVersion >= UseOffice.eOfficeVersion.Office2013)
            {
                // Converting ...
                int result = u.ConvertFile(inpFile, outFile, UseOffice.eDirection.PDF_to_RTF);

                if (result == 0)
                {
                    Console.WriteLine("Converting successfully!");
                    // Open the result.
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                    {
                        UseShellExecute = true
                    });
                }
                else
                {
                    Console.WriteLine("Error! Please contact with SautinSoft support: [email protected].");
                }
            }
            else
            {
                Console.WriteLine("To convert PDF documents, please install MS Office 2013 or higher.");
            }
            u.CloseOffice();
        }
        static void Main(string[] args)
        {
            //Convert DOC file to HTML file

            SautinSoft.UseOffice u = new SautinSoft.UseOffice();

            //Path to any local file
            string inputFilePath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"d:\Tempos\sample.doc"));
            //Path to output resulted file
            string outputFilePath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"d:\Tempos\sample.html"));

            //Prepare UseOffice .Net, loads MS Word in memory
            int ret = u.InitWord();

            //Return values:
            //0 - Loading successfully
            //1 - Can't load MS Word® library in memory

            if (ret == 1)
            {
                return;
            }

            //Converting
            ret = u.ConvertFile(inputFilePath, outputFilePath, SautinSoft.UseOffice.eDirection.DOC_to_HTML);

            //Release MS Word from memory
            u.CloseWord();

            //0 - Converting successfully
            //1 - Can't open input file. Check that you are using full local path to input file, URL and relative path are not supported
            //2 - Can't create output file. Please check that you have permissions to write by this path or probably this path already used by another application
            //3 - Converting failed, please contact with our Support Team
            //4 - MS Office isn't installed. The component requires that any of these versions of MS Office should be installed: 2000, XP, 2003, 2007 or 2010
            if (ret == 0)
            {
                //Show produced file
                System.Diagnostics.Process.Start(outputFilePath);
            }
        }