コード例 #1
0
        static void Main(string[] args)
        {
            if (!Directory.Exists(OutputFolder))
            {
                Directory.CreateDirectory(OutputFolder);
            }

            // Create LineDetector instance and load document
            LineDetector lineDetector = new LineDetector("demo", "demo");

            lineDetector.LoadDocumentFromFile(InputFile);

            // Create RasterRenderer instance and load document
            RasterRenderer rasterRenderer = new RasterRenderer("demo", "demo");

            rasterRenderer.LoadDocumentFromFile(InputFile);

            try
            {
                int pageCount = lineDetector.GetPageCount();

                for (int pageIndex = 0; pageIndex < pageCount; pageIndex++)
                {
                    Console.WriteLine("Processing page #{0}", pageIndex);

                    // Find horizontal lines on the page
                    FoundLinesCollection horzLines = lineDetector.FindLines(pageIndex, LineOrientationsToFind.OnlyHorizontal);
                    // Slice page by separating lines and create new PDF documents
                    Slice(pageIndex, horzLines, rasterRenderer);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
            finally
            {
                // Cleanup
                rasterRenderer.Dispose();
                lineDetector.Dispose();
            }


            Console.WriteLine();
            Console.WriteLine("Press any key...");
            Console.ReadKey();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // Create Bytescout.PDFExtractor.LineDetector instance
            LineDetector lineDetector = new LineDetector();

            lineDetector.RegistrationName = "demo";
            lineDetector.RegistrationKey  = "demo";

            // Load sample PDF document
            lineDetector.LoadDocumentFromFile(@".\sample2.pdf");

            FoundLinesCollection foundLines = lineDetector.FindLines(1, LineOrientationsToFind.HorizontalAndVertical);

            Console.WriteLine("Number of lines found: " + foundLines.Count);

            for (int i = 0; i < foundLines.Count; i++)
            {
                FoundLine line = foundLines[i];

                Console.WriteLine("Line # " + i);

                // Line Orientation
                Console.WriteLine("LineOrientation: " + line.LineOrientation);

                // Starting point of the line
                Console.WriteLine("From point: " + line.From);

                // Ending point of the line
                Console.WriteLine("To point: " + line.To);

                // Line width
                Console.WriteLine("Width: " + line.Width);
            }

            Console.ReadLine();
        }