예제 #1
0
        public void Handle(string issueFilePath, string outputFolderPath, string userName, string password)
        {
            if (string.IsNullOrWhiteSpace(issueFilePath))
            {
                //error
            }

            string fileName  = Path.GetFileNameWithoutExtension(issueFilePath);
            string issueDate = fileName.Split('_')[1];

            string issueYear             = issueDate.Substring(0, 4);
            string issueOutputFolderPath = Path.Combine(outputFolderPath, issueYear, issueDate);

            if (!Directory.Exists(issueOutputFolderPath))
            {
                Console.WriteLine("Creating folder for issue {0} at {1}", issueDate, issueOutputFolderPath);
                Directory.CreateDirectory(issueOutputFolderPath);
            }
            var conversionActions = new BondiDJVUActions();

            conversionActions.Open(issueFilePath, userName, password);

            int pageCount = conversionActions.PageCount;

            Console.WriteLine("Starting to process issue {0}.", issueDate);
            Console.WriteLine("Issue {0} has {1} pages.", issueDate, pageCount);

            try
            {
                for (int i = 0; i < pageCount; i++)
                {
                    Console.WriteLine("Starting to process page {0} of issue {1}", i + 1, issueDate);


                    var pageSize = conversionActions.GetPageSize(i);

                    var height = pageSize.Height;
                    var width  = pageSize.Width;

                    Console.WriteLine("Issue:{0} Page:{1} Height:{2} Width:{3}", issueDate, i + 1, height, width);

                    var pageFileName       = string.Format("{0}.{1}", (i + 1), "jpeg");
                    var pageOutputFilePath = Path.Combine(issueOutputFolderPath, pageFileName);

                    Console.WriteLine("Issue:{0} Page:{1} OutputFilePath:{2}", issueDate, i + 1, pageOutputFilePath);
                    conversionActions.SavePageBitmap(pageOutputFilePath, i, width, height);

                    GC.Collect();
                }
            }
            catch (Exception ex)
            {
                //TODO: decide what the hell to do?
                // maybe we just delete the folder and stop caring?
            }

            conversionActions.Close();
        }
예제 #2
0
        public Size GetPageSize(int pageIndex)
        {
            if (pageIndex < 0 || pageIndex > this.LastPageIndex)
            {
                return(Size.Empty);
            }

            if (!this.pageSizeArray[pageIndex].IsEmpty)
            {
                return(this.pageSizeArray[pageIndex]);
            }

            BondiDJVUActions.SIZE size = new BondiDJVUActions.SIZE();

            if (!BondiDJVUActions.GetPageSize(pageIndex, ref size))
            {
                return(Size.Empty);
            }

            this.pageSizeArray[pageIndex] = size.Size;
            return(this.pageSizeArray[pageIndex]);
        }