How to convert PDF to Text programmatically in C#
Modify document with C#, VB.NET, ASP.NET from Sautin Software company
google+ facebook twitter youtube    

 

 

How to convert PDF to Text programmatically in C#

If you are looking for a good solution for converting PDF files to a Text programmatically, try our PDF Focus .Net.
back to PDF Focus .Net

 

1. Convert PDF file to Text in C# and .Net:

					        public static void PdfToWordAsFiles()
        {
            string pdfFile = @"d:\Zoo.pdf";
            string docxFile = Path.ChangeExtension(pdfFile, ".docx");

            PdfFocus f = new PdfFocus();
            f.WordOptions.Format = PdfFocus.CWordOptions.eWordDocument.Docx;
            f.WordOptions.DetectTables = true;

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                f.ToWord(docxFile);
            }
        }
				

2. Convert PDF to Text in memory using MemoryStream in C#:

					        public static void PdfToWordAsMemoryStream()
        {
            string pdfFile = @"d:\Zoo.pdf";
            string docxFile = Path.ChangeExtension(pdfFile, ".docx");

            PdfFocus f = new PdfFocus();

            using (FileStream pdfStream = new FileStream(pdfFile, FileMode.Open))
            {
                f.OpenPdf(pdfStream);
                if (f.PageCount > 0)
                {
                    using (MemoryStream docxStream = new MemoryStream(f.ToWord()))
                    {
                        // Here we have the .docx result as MemoryStream
                    }
                }
            }
        }
				

3. Convert PDF to Text in memory as byte[] using C#:

					        public static void PdfToWordAsByteArray()
        {
            byte[] pdfBytes = File.ReadAllBytes(@"d:\Zoo.pdf");
            byte[] docxBytes = null;

            PdfFocus f = new PdfFocus();

            f.OpenPdf(pdfBytes);
            
            if (f.PageCount > 0)
            {
                docxBytes = f.ToWord();
                // Here we have the .docx result as byte[]
            }
        }
				

PDF Focus - Top Questions

 

 

components for devolopers
HOME
Since 2002, Sautin Software has been developing and marketing .Net libraries that make it simple to process PDF, HTML and RTF files
I  Validator
Copyright © 2002 - 2017 Sautin Software. All rights reserved support@sautin.com