コード例 #1
0
ファイル: UtilManager.cs プロジェクト: wtang2006/SpiderWeb
        /*
         * Explodes a pdf
         * */
        public static List<string> explodePdf(String inFile, String extractor, String repair)
        {

            FileInfo f = new FileInfo(inFile);
            inFile = f.FullName;
            List<string> theParts = new List<string>();

            try
            {
                CMDUtil cmd = new CMDUtil();
                UtilManager.repairPDF(inFile, repair);
                PdfReader reader = new PdfReader(inFile);
                int n = reader.NumberOfPages;
                String str;
                cmd.explode(inFile, extractor, "1-" + n);
                for (int i = 0; i < n; i++)
                {
                    str = f.FullName.Replace(".pdf", "-x" + (i + 1) + ".pdf");
                    UtilManager.repairPDF(str, repair);
                    theParts.Add(str);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.StackTrace);
            }
            System.Diagnostics.Debug.WriteLine("Exploded: " + theParts);
            return theParts;
        }
コード例 #2
0
ファイル: UtilManager.cs プロジェクト: wtang2006/SpiderWeb
        /**
         * Repairs the pdf
         * */
        public static void repairPDF(String file, String repairer)
        {

            try
            {
                CMDUtil c = new CMDUtil();
                String uniqueFile = UtilManager.getUniqueFile("C:\\windows\\temp\\", "pdf");
                FileManager fManager = new FileManager();
                FileInfo f = new FileInfo(file);
                if (f.Exists)
                {
                    c.repairPDF(file, uniqueFile, repairer);
                    f = new FileInfo(uniqueFile);
                    if (f.Exists && f.Length > 0)
                    {
                        File.Copy(uniqueFile, file);
                        //fManager.deleteFile(uniqueFile);
                    }

                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("ERROR: Repairing file (" + file + ") does not exist.");
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.StackTrace);
            }

        }