private void OnMarkupActivated(object sender, System.EventArgs e) { if (ndocument == null) { StyleSelectDialog dialog = new StyleSelectDialog (); if (dialog.Run () == (int) ResponseType.Ok) { try { string format = dialog.Box.ActiveText; if (format != null) ndocument = rdocument.Normalize (format); MarkupHTML marker = new MarkupHTML (ndocument); html_document = marker.CreateHTMLDocument (); textview.Buffer.Text = html_document.GetText (); Markup.Sensitive = false; Normalize.Sensitive = false; Preview.Sensitive = true; } catch (StyleException exception){ MessageDialog md = new MessageDialog (this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, exception.Message); md.Run (); md.Destroy(); } catch (NormalizerException exception){ MessageDialog md = new MessageDialog (this, DialogFlags.DestroyWithParent, MessageType.Error, ButtonsType.Ok, exception.Message); md.Run (); md.Destroy(); } } dialog.Destroy (); } else { MarkupHTML marker = new MarkupHTML (ndocument); html_document = marker.CreateHTMLDocument (); textview.Buffer.Text = html_document.GetText (); Markup.Sensitive = false; Normalize.Sensitive = false; Preview.Sensitive = true; } }
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); } } } } }