Exemple #1
0
            public void CreateInstanceWithInvalidUri()
            {
                Uri uri = new Uri ("/foo/v17n01a02.pdf");

                try {
                PDFPoppler doc = new PDFPoppler (uri);
                Type etype = Type.GetType ("Scielo.PDF2Text.PDFPoppler");
                Assert.IsNotInstanceOfType (etype, doc, "CI01");
                Assert.IsNull (doc, "CI02");
                } catch (FileNotFoundException) {
                Console.WriteLine ("Error: El archivo no existe.");
                }
            }
Exemple #2
0
        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 ();
        }
Exemple #3
0
            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);
                    }
                }
                }
                }
            }