Exemplo n.º 1
0
 private void AppendIt(string fp)
 {
     Int64 cbPDF = new FileInfo(fp).Length;
     if (String.Compare(".pdf", Path.GetExtension(fp), true) == 0) {
         String prefixOut = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));
         ProcessStartInfo psi = new ProcessStartInfo(EUt.pdftoppm, " -scale-to " + W + " -jpeg \"" + fp + "\" \"" + prefixOut + "\" ");
         psi.UseShellExecute = false;
         psi.CreateNoWindow = true;
         Process p = Process.Start(psi);
         p.WaitForExit();
         Debug.Assert(p.ExitCode == 0, String.Format("PDFからサムネイル画像を作成する事に失敗しました。({0})", p.ExitCode));
         List<Pane> perPDF = new List<Pane>();
         for (int x = 1; ; x++) {
             String fpJPG = prefixOut + "-" + x + ".jpg";
             if (!File.Exists(fpJPG)) {
                 fpJPG = prefixOut + "-" + x.ToString("00") + ".jpg";
                 if (!File.Exists(fpJPG)) {
                     fpJPG = prefixOut + "-" + x.ToString("000") + ".jpg";
                     if (!File.Exists(fpJPG)) {
                         fpJPG = prefixOut + "-" + x.ToString("0000") + ".jpg";
                         if (!File.Exists(fpJPG)) {
                             break;
                         }
                     }
                 }
             }
             Bitmap picJPG = new Bitmap(fpJPG);
             Pane pane = new Pane();
             pane.AutoSize = true;
             pane.Image = picJPG;
             pane.Margin = new Padding(1);
             pane.fpSrc = fp;
             pane.iPage = x;
             pane.Name = Guid.NewGuid().ToString("N");
             pane.ThumbnailWidth = W + 2;
             perPDF.Add(pane);
             flpPages.Controls.Add(pane);
         }
         foreach (Pane pane in perPDF) {
             pane.cbSave = cbPDF / perPDF.Count;
         }
         if (String.IsNullOrEmpty(fbdSave.SelectedPath)) {
             fbdSave.SelectedPath = Path.GetDirectoryName(fp);
         }
     }
     else if ("|.tif|.tiff|".IndexOf("|" + Path.GetExtension(fp) + "|", StringComparison.InvariantCultureIgnoreCase) >= 0) {
         String fppdf = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N") + ".pdf");
         ProcessStartInfo psi = new ProcessStartInfo(EUt.tiff2pdf, " -o \"" + fppdf.Replace("\\", "\\\\") + "\" \"" + fp.Replace("\\", "\\\\") + "\"");
         psi.UseShellExecute = false;
         psi.CreateNoWindow = true;
         Process p = Process.Start(psi);
         p.WaitForExit();
         Debug.Assert(p.ExitCode == 0, String.Format("TIFFからPDFへの変換に失敗しました。({0})", p.ExitCode));
         if (String.IsNullOrEmpty(fbdSave.SelectedPath)) {
             fbdSave.SelectedPath = Path.GetDirectoryName(fp);
         }
         AppendIt(fppdf);
     }
 }
Exemplo n.º 2
0
 public void AddPane(Pane p)
 {
     panes.Add(p);
 }
Exemplo n.º 3
0
 public void AddPane(Pane p)
 {
     panes.Add(p);
 }