예제 #1
0
        public bool ConvertPDFFolder2EPS(string inConvertFolderPath,
                                         string inTargetFolderPath,
                                         string inConvertFileWildCard,
                                         bool inDeleteSourcePDF,
                                         bool inSearchSubFolders,
                                         double inFirstPageToConvert,
                                         double inLastPageToConvert)
        {
            //          logger.Info("inConvertFolderPath = " + inConvertFolderPath + ", inTargetFolderPath = " + inTargetFolderPath +
            //                      ", inConvertFileWildCard = " + inConvertFileWildCard + ", inDeleteSourcePDF = " + inDeleteSourcePDF + ", inSearchSubFolders = " + inSearchSubFolders +
            //                      ", inFirstPageToConvert = " + inFirstPageToConvert + ", inLastPageToConvert = " + inLastPageToConvert);

            bool conversionSucceed;

            System.IO.DirectoryInfo root = new System.IO.DirectoryInfo(inConvertFolderPath);

            // Convert all files in folder.
            FileConverter fileConvertor = InstancesManager.GetObject(InstancesManager.ConversionType.PDF2EPS);

            conversionSucceed = WalkDirectoryTreePDF2EPS(fileConvertor, root, inTargetFolderPath, inConvertFileWildCard, inDeleteSourcePDF, inSearchSubFolders,
                                                         inConvertFolderPath.Equals(inTargetFolderPath), inFirstPageToConvert, inLastPageToConvert);
            InstancesManager.PutObject(InstancesManager.ConversionType.PDF2EPS, fileConvertor);

            return(conversionSucceed);
        }
예제 #2
0
        public bool ConvertPDF2PNG(string inConvertFilePath,
                                   string inNewFileTargetFolderPath,
                                   double inResolutionX,
                                   double inResolutionY,
                                   double inGraphicsAlphaBitsValue,
                                   double inTextAlphaBitsValue)
        {
            //          logger.Info("inConvertFilePath = " + inConvertFilePath + ", inNewFileTargetFolderPath = " + inNewFileTargetFolderPath +
            //                      ", inResolutionX = " + inResolutionX + ", inResolutionY = " + inResolutionY + ", inGraphicsAlphaBitsValue = " + inGraphicsAlphaBitsValue +
            //                      ", inTextAlphaBitsValue = " + inTextAlphaBitsValue + ");

            bool conversionSucceed;

            CheckBaseParamsValidation(inResolutionX, inResolutionY, inGraphicsAlphaBitsValue, inTextAlphaBitsValue);

            // Make the conversion.
            FileConverter fileConvertor = InstancesManager.GetObject(InstancesManager.ConversionType.PDF2PNG);

            conversionSucceed = fileConvertor.ConvertPDF2PNG(inConvertFilePath, inNewFileTargetFolderPath, inResolutionX, inResolutionY, inGraphicsAlphaBitsValue, inTextAlphaBitsValue);
            InstancesManager.PutObject(InstancesManager.ConversionType.PDF2PNG, fileConvertor);

            // Rename PNG names to the correct page counter.
            RenameImagesNames(inNewFileTargetFolderPath, inConvertFilePath, "png");


            return(conversionSucceed);
        }
예제 #3
0
        public bool ConvertPDFFolder2PNG(string inConvertFolderPath,
                                         string inTargetFolderPath,
                                         string inConvertFileWildCard,
                                         bool inDeleteSourcePDF,
                                         bool inSearchSubFolders,
                                         double inResolutionX,
                                         double inResolutionY,
                                         double inGraphicsAlphaBitsValue,
                                         double inTextAlphaBitsValue)
        {
            //          logger.Info("inConvertFolderPath = " + inConvertFolderPath + ", inTargetFolderPath = " + inTargetFolderPath +
            //                      ", inConvertFileWildCard = " + inConvertFileWildCard + ", inDeleteSourcePDF = " + inDeleteSourcePDF + ", inSearchSubFolders = " + inSearchSubFolders +
            //                      ", inResolutionX = " + inResolutionX + ", inResolutionY = " + inResolutionY + ", inGraphicsAlphaBitsValue = " + inGraphicsAlphaBitsValue +
            //                       ", inTextAlphaBitsValue = " + inTextAlphaBitsValue);

            bool conversionSucceed;

            CheckBaseParamsValidation(inResolutionX, inResolutionY, inGraphicsAlphaBitsValue, inTextAlphaBitsValue);

            System.IO.DirectoryInfo root = new System.IO.DirectoryInfo(inConvertFolderPath);

            // Convert all files in folder.
            FileConverter fileConvertor = InstancesManager.GetObject(InstancesManager.ConversionType.PDF2PNG);

            conversionSucceed = WalkDirectoryTreePDF2PNG(fileConvertor, root, inTargetFolderPath, inConvertFileWildCard, inDeleteSourcePDF, inSearchSubFolders, inConvertFolderPath.Equals(inTargetFolderPath), inResolutionX, inResolutionY, inGraphicsAlphaBitsValue, inTextAlphaBitsValue);
            InstancesManager.PutObject(InstancesManager.ConversionType.PDF2PNG, fileConvertor);

            return(conversionSucceed);
        }
예제 #4
0
 protected override void OnStop()
 {
     if (_serviceHost != null)
     {
         _serviceHost.Close();
         InstancesManager.DeleteDynamicLoadingDLL();
         _serviceHost = null;
     }
 }
예제 #5
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[]
            {
                new GhostscriptService()
            };
            ServiceBase.Run(ServicesToRun);

            InstancesManager.DeleteDynamicLoadingDLL();
        }
예제 #6
0
        public bool ConvertPDF2LowResPDF(string inConvertFilePath, string inNewFileTargetPath)
        {
            //          logger.Info("inConvertFilePath = " + inConvertFilePath + ", inNewFileTargetPath = " + inNewFileTargetPath);

            bool conversionSucceed;

            // Make the conversion.
            FileConverter fileConvertor = InstancesManager.GetObject(InstancesManager.ConversionType.PDF2LowResPDF);

            conversionSucceed = fileConvertor.ConvertPDF2LowResPDF(inConvertFilePath, inNewFileTargetPath);
            InstancesManager.PutObject(InstancesManager.ConversionType.PDF2LowResPDF, fileConvertor);

            return(conversionSucceed);
        }
예제 #7
0
        public bool ConvertPDF2EPS(string inConvertFilePath, string inNewFileTargetPath, double inFirstPageToConvert, double inLastPageToConvert)
        {
            //          logger.Info("inConvertFilePath = " + inConvertFilePath + ", inNewFileTargetPath = " + inNewFileTargetPath +
            //                      ", inFirstPageToConvert = " + inFirstPageToConvert + ", inLastPageToConvert = " + inLastPageToConvert);

            bool conversionSucceed;

            // Make the conversion.
            FileConverter fileConvertor = InstancesManager.GetObject(InstancesManager.ConversionType.PDF2EPS);

            conversionSucceed = fileConvertor.ConvertPDF2EPS(inConvertFilePath, inNewFileTargetPath, inFirstPageToConvert, inLastPageToConvert);
            InstancesManager.PutObject(InstancesManager.ConversionType.PDF2EPS, fileConvertor);

            return(conversionSucceed);
        }
예제 #8
0
        protected override void OnStart(string[] args)
        {
            if (_serviceHost != null)
            {
                _serviceHost.Close();
            }

            //Delete previous dynamic loading DLLs if there are any.
            InstancesManager.DeleteDynamicLoadingDLL();

            // Create a ServiceHost for the ConvertToPdfService type and provide the base address.
            _serviceHost = new ServiceHost(typeof(ConverterService));

            // Open the ServiceHostBase to create listeners and start listening for messages.
            _serviceHost.Open();
        }
예제 #9
0
        static void Main()
        {
            AllocConsole();

            string testFolder   = "..\\..\\Tests\\";
            string outputFolder = testFolder + "Output\\";
            string inputFolder  = testFolder + "Input\\";
            int    numRepeats   = 1;

            if (!System.IO.Directory.Exists(testFolder))
            {
                System.IO.Directory.CreateDirectory(testFolder);
            }
            if (!System.IO.Directory.Exists(outputFolder))
            {
                System.IO.Directory.CreateDirectory(outputFolder);
            }

            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(outputFolder);
            foreach (System.IO.DirectoryInfo dir in di.GetDirectories())
            {
                dir.Delete(true);
            }
            foreach (System.IO.FileInfo file in di.GetFiles())
            {
                file.Delete();
            }

            Console.WriteLine("Start Test");
            Stopwatch stopWatch      = new Stopwatch();
            Stopwatch iterationWatch = new Stopwatch();
            TimeSpan  ts;

            stopWatch.Start();

            ConverterService converter = new ConverterService();

            for (int i = 1; i <= numRepeats; ++i)
            {
                iterationWatch.Reset();
                iterationWatch.Start();

                //converter.ConvertPDF2JPG(inputFolder + "Sample.pdf", outputFolder, 72, 72, 1, 1, 72);
                //converter.ConvertPDF2EPS(inputFolder + "Sample.pdf", outputFolder + i.ToString() + ".ps",1,1);
                //converter.ConvertEPS2PDF(outputFolder + i.ToString() + ".ps", outputFolder + i.ToString() + ".pdf");
                //converter.ConvertEPS2LowResPDF(outputFolder + i.ToString() + ".ps", outputFolder + i.ToString() + "_lowres.pdf");
                //converter.ConvertImage2LowResImage(inputFolder + "ImageTest.jpg", inputFolder + i.ToString() + ".jpg");
                //converter.ConvertImage2LowResImage(inputFolder + "Sample.TIF", outputFolder + i.ToString() + ".tif");
                //converter.ConvertImage2LowResImage(inputFolder + "Sample.jpg", outputFolder + i.ToString() + ".jpg");
                //converter.ConvertImage2LowResImage(inputFolder + "Sample.png", outputFolder + i.ToString() + ".png");
                //converter.ConvertImage2LowResImage(inputFolder + "Sample.gif", outputFolder + i.ToString() + ".gif");
                //converter.ConvertPDF2PNGSingle(inputFolder + "Sample.pdf", outputFolder + "Sample.png", 72, 72, 2, 4);
                converter.ConvertPDFFolder2PNG(inputFolder, outputFolder, "*.pdf", true, true, 72, 72, 2, 4);

                iterationWatch.Stop();
                ts = iterationWatch.Elapsed;
                Console.WriteLine("RunTime iteration {0} {1:00}:{2:00}:{3:00}.{4:000}", i, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
            }

            stopWatch.Stop();
            ts = stopWatch.Elapsed;
            Console.WriteLine("");
            Console.WriteLine("Total Run Time: {0:00}:{1:00}:{2:00}.{3:000}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
            ts = TimeSpan.FromMilliseconds(ts.TotalMilliseconds / numRepeats);
            Console.WriteLine("Avrag Run Time: {0:00}:{1:00}:{2:00}.{3:000}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);

            InstancesManager.DeleteDynamicLoadingDLL();
            Console.ReadLine();

            /*
             * Worker workerObject = new Worker();
             * Thread workerThread = new Thread(workerObject.DoWork1);
             * //workerThread.Start();
             *
             * Worker workerObject2 = new Worker();
             * Thread workerThread2 = new Thread(workerObject.DoWork2);
             * //workerThread2.Start();
             *
             * Worker workerObject3 = new Worker();
             * Thread workerThread3 = new Thread(workerObject.DoWork3);
             * //workerThread3.Start();
             *
             * Worker workerObject4 = new Worker();
             * Thread workerThread4 = new Thread(workerObject.DoWork4);
             * //workerThread4.Start();
             *
             * //convert.ConvertFileType("C:\\gs\\PDF\\Folder2\\2Text_graph_image_cmyk_rgb.pdf", "C:\\gs\\JPG\\Folder2", wild.Length, "jpg");
             *
             * convert.ConvertFileTypeNestedFolders(convertFolderPath, targetFolderPath, "*.pdf", "jpg");
             *
             * sw.Stop();
             * Console.WriteLine("Elapsed={0}", sw.ElapsedMilliseconds/1000);
             *
             * workerThread.Join();
             * workerThread2.Join();
             */
        }