private void OnOpenActivated(object sender, System.EventArgs e) { OpenPDFDialog dialog = new OpenPDFDialog (); if (dialog.Run () == (int) ResponseType.Ok) { Uri uri = new Uri (dialog.Document); PDFPoppler reader = new PDFPoppler (uri); //Extracting images from document reader.GetNonText (); //Extracting text from document rdocument = reader.CreateRawDocument (); textview.Buffer.Text = rdocument.GetText (); Markup.Sensitive = true; Normalize.Sensitive = true; store.Clear (); // Logger.ClearList (); } dialog.Destroy (); }
public static void Main(string[] args) { Uri uri; PDFPoppler reader; RawDocument rdoc; NormDocument ndoc; MarkupHTML marker; HTMLDocument htmldoc; string filepath, format, num; AppOptions options = new AppOptions (args); #if DEBUG Logger.ActivateDebug (); #endif if (options.GotNoArguments) { Application.Init (); MarkerWindow win = new MarkerWindow (); win.Show (); Application.Run (); } else { if (!options.Format && !options.numColumns) { options.DoHelp (); Environment.Exit (0); } else if (!options.GotNoArguments && options.Format) { format = options.FirstArgument; filepath = options.SecondArgument; uri = ParsePath (filepath); if (uri != null) { try { reader = new PDFPoppler (uri); Logger.Debug ("Transformando PDF", ""); rdoc = reader.CreateRawDocument (); ndoc = rdoc.Normalize (format); ndoc.WriteDocument (Environment.CurrentDirectory, Path.GetFileNameWithoutExtension (filepath), "norm"); marker = new MarkupHTML (ndoc); htmldoc = marker.CreateHTMLDocument (); htmldoc.WriteDocument (Environment.CurrentDirectory, Path.GetFileNameWithoutExtension (filepath), "htm"); reader.GetNonText (); Logger.Debug ("Finalizando", ""); } catch (FileNotFoundException) { Logger.Error ("El archivo {0} no existe", filepath); Environment.Exit (1); } } else { Logger.Error ("Solo se acepta la ruta a un documento PDF", ""); Environment.Exit (1); } } else if (!options.GotNoArguments && options.numColumns) { num = options.FirstArgument; filepath = options.SecondArgument; format = options.ThirdArgument; uri = ParsePath (filepath); if (uri != null) { try { Console.WriteLine ("En opcion de columnas"); reader = new PDFPoppler (uri); Console.WriteLine ("Transformando PDF ... "); rdoc = reader.CreateRawDocument (); Console.WriteLine ("Buscando las {0} columnas.", num); rdoc.BreakColumns(); Console.WriteLine ("Rompio las {0} columnas here......", rdoc.GetText()); rdoc.WriteDocument (Environment.CurrentDirectory, Path.GetFileNameWithoutExtension (filepath), "column"); Console.WriteLine ("Finalizando\n"); } catch (FileNotFoundException) { Console.WriteLine ("Error: El archivo {0} no existe.", filepath); Environment.Exit (1); } } } } }