示例#1
0
        static void Main(string[] args)
        {
            /*
             * Please note: Streams can be read/write to azure blobs, so in this example,
             * we're demonstrating how to read pdf from stream, convert to csv,
             * and write to csv stream
             */

            // Create Bytescout.PDFExtractor.CSVExtractor instance
            CSVExtractor extractor = new CSVExtractor();

            extractor.RegistrationName = "demo";
            extractor.RegistrationKey  = "demo";

            // Get input stream
            var inputStream = GetMemoryStream("sample3.pdf");

            // Load sample PDF document from stream
            extractor.LoadDocumentFromStream(inputStream);

            // you can change CSV separator symbol (if needed) from "," symbol to another if needed for non-US locales
            //extractor.CSVSeparatorSymbol = ",";

            // Save extracted CSV data to output stream
            var outputStream = new MemoryStream();

            extractor.SaveCSVToStream(outputStream);

            // Save output stream to file, so we can take a look
            WriteStreamToFile(outputStream, "output.csv");

            // Cleanup
            extractor.Dispose();

            Console.WriteLine();
            Console.WriteLine("Data has been extracted to 'output.csv' file.");
            Console.WriteLine();
            Console.WriteLine("Press any key to continue and open CSV in default CSV viewer (or Excel)...");
            Console.ReadKey();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("output.csv");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }