Example #1
0
        static void Main(string[] args)
        {
            // Extract all images from 1st PDF page
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // This property is necessary only for registered version
            // f.Serial = "XXXXXXXXXXX";
            string pdfFile  = @"..\..\simple text.pdf";
            string imageDir = new DirectoryInfo(Directory.GetCurrentDirectory()).CreateSubdirectory("images").FullName;

            List <PdfFocus.PdfImage> pdfImages = null;

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                pdfImages = f.ExtractImages(1, 1);

                // Show all extracted images.
                if (pdfImages != null && pdfImages.Count > 0)
                {
                    for (int i = 0; i < pdfImages.Count; i++)
                    {
                        string imageFile = Path.Combine(imageDir, String.Format("img{0}.png", i + 1));
                        pdfImages[i].Picture.Save(imageFile);
                    }
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(imageDir)
                    {
                        UseShellExecute = true
                    });
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            // Extract all images from PDF
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // This property is necessary only for registered version
            // f.Serial = "XXXXXXXXXXX";
            string pdfFile  = @"..\..\..\..\..\simple text.pdf";
            string imageDir = Path.GetDirectoryName(pdfFile);

            List <PdfFocus.PdfImage> pdfImages = null;

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                // Rasterize all vector graphics
                f.ImageExtractionOptions.RasterizeComplexGraphics = true;

                pdfImages = f.ExtractImages();

                // Show all extracted images.
                if (pdfImages != null && pdfImages.Count > 0)
                {
                    for (int i = 0; i < pdfImages.Count; i++)
                    {
                        string imageFile = Path.Combine(imageDir, String.Format("img{0}.png", i + 1));
                        pdfImages[i].Picture.Save(imageFile);
                        System.Diagnostics.Process.Start(imageFile);
                    }
                }
            }
        }
Example #3
0
        static void Main(string[] args)
        {
            //foreach (string file in Directory.EnumerateFiles(@"C:\Users\yanswong\source\repos\Convert PDF file to Excel file\C#\SW\", "*.pdf"))
            foreach (string file in Directory.EnumerateFiles(@"C:\Users\yanswong\Desktop\CMM\May-2017\", "*.pdf", SearchOption.AllDirectories))
            //foreach (string [] file in Directory.GetDirectories(@"\\pngnas2.mys.agilent.com\EUC_Gshare\vpdpenang\VPD LDA\VPD LDA\CMM MEASUREMENT RESULT\2018\","*",SearchOption.AllDirectories))
            {
                //string pathToPdf = @"C:\Users\yanswong\source\repos\Convert PDF file to Excel file\C#\SW\3700391-115-01-18-2.pdf";
                //string pathToExcel = Path.ChangeExtension(pathToPdf, ".xls");
                string pathToExcel = Path.ChangeExtension(file, ".xls");
                // Convert PDF file to Excel file
                SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

                // 'true' = Convert all data to spreadsheet (tabular and even textual).
                // 'false' = Skip textual data and convert only tabular (tables) data.
                f.ExcelOptions.ConvertNonTabularDataToSpreadsheet = true;

                // 'true'  = Preserve original page layout.
                // 'false' = Place tables before text.
                f.ExcelOptions.PreservePageLayout = true;

                //f.OpenPdf(pathToPdf);
                f.OpenPdf(file);
                if (f.PageCount > 0)
                {
                    int result = f.ToExcel(pathToExcel);

                    //Open a produced Excel workbook
                    //if (result==0)
                    //{
                    //    System.Diagnostics.Process.Start(pathToExcel);
                    //}
                }
            }
        }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Cursor       = Cursors.WaitCursor;
            lblConversao.Text = "";
            lblCaminho.Text   = "";
            try
            {
                SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
                caminho = @escolherArquivo();
                f.OpenPdf(@caminho);
                //string caminho = (Environment.GetFolderPath caminho);

                if (f.PageCount > 0)
                {
                    string destino = @Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + @"\Conversao"
                                     + nomeArquivo.Replace(".", "") + ".docx";
                    f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Docx;
                    f.ToWord(destino);

                    lblConversao.ForeColor = Color.Green;
                    lblConversao.Text      = destino;
                }
            }
            catch (Exception ex)
            {
                lblConversao.ForeColor = Color.Red;
                lblConversao.Text      = "Erro:  " + ex.Message;
            }
            this.Cursor = Cursors.Default;
        }
Example #5
0
        static void Main(string[] args)
        {
            string pdfFile  = @"..\..\..\..\..\Text.pdf";
            string htmlFile = Path.ChangeExtension(pdfFile, ".htm");

            // Convert PDF file to HTML file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // Let's change all text to Verdana 8pt.
            f.HtmlOptions.SingleFontFamily = "Verdana";
            f.HtmlOptions.SingleFontSize   = 8;


            // After purchasing the license, please insert your serial number here to activate the component:
            //f.Serial = "123456789";

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                int from = 1;
                int to   = (3 > f.PageCount) ? f.PageCount : 3;

                int result = f.ToHtml(htmlFile, from, to);

                // Show resulted HTML document in a browser.
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(htmlFile);
                }
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            // Extract all images with width and height more than 200px
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            string pdfFile  = @"D:\Personal_GitHub\ExtractimagesFromPDF\PdfUtils\ReadPdfImage\Data\dipak.pdf";
            string imageDir = Path.GetDirectoryName(pdfFile);

            List <PdfFocus.PdfImage> pdfImages = null;

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                // Specify to extract only images which have width and height
                // more than 200px
                f.ImageExtractionOptions.MinSize = new System.Drawing.Size(200, 200);

                pdfImages = f.ExtractImages();

                // Show all extracted images.
                if (pdfImages != null && pdfImages.Count > 0)
                {
                    for (int i = 0; i < pdfImages.Count; i++)
                    {
                        string imageFile = Path.Combine(imageDir, String.Format("img{0}.png", i + 1));
                        pdfImages[i].Picture.Save(imageFile);
                        System.Diagnostics.Process.Start(imageFile);
                    }
                }
            }
        }
Example #7
0
        static void Main(string[] args)
        {
            // Extract all images with width and height more than 200px
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // This property is necessary only for registered version
            // f.Serial = "XXXXXXXXXXX";
            string pdfFile  = @"..\..\..\..\..\simple text.pdf";
            string imageDir = Path.GetDirectoryName(pdfFile);

            List <PdfFocus.PdfImage> pdfImages = null;

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                // Specify to extract only images which have width and height
                // more than 200px
                f.ImageExtractionOptions.MinSize = new System.Drawing.Size(200, 200);

                pdfImages = f.ExtractImages();

                // Show all extracted images.
                if (pdfImages != null && pdfImages.Count > 0)
                {
                    for (int i = 0; i < pdfImages.Count; i++)
                    {
                        string imageFile = Path.Combine(imageDir, String.Format("img{0}.png", i + 1));
                        pdfImages[i].Picture.Save(imageFile);
                        System.Diagnostics.Process.Start(imageFile);
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            string pathToPdf   = @"d:\Tempos\Table.pdf";
            string pathToExcel = Path.ChangeExtension(pathToPdf, ".xls");

            // Convert PDF file to Excel file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // 'true' = Convert all data to spreadsheet (tabular and even textual).
            // 'false' = Skip textual data and convert only tabular (tables) data.
            f.ExcelOptions.ConvertNonTabularDataToSpreadsheet = true;

            // 'true'  = Preserve original page layout.
            // 'false' = Place tables before text.
            f.ExcelOptions.PreservePageLayout = true;

            f.OpenPdf(pathToPdf);

            if (f.PageCount > 0)
            {
                int result = f.ToExcel(pathToExcel);

                //Open a produced Excel workbook
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(pathToExcel);
                }
            }
        }
        static void Main(string[] args)
        {
            string pathToPdf  = @"d:\Tempos\table.pdf";
            string pathToHtml = Path.ChangeExtension(pathToPdf, ".htm");

            // Convert PDF file to HTML file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            // You may download the latest version of SDK here:
            // www.sautinsoft.com/products/pdf-focus/download.php


            // Let's force the component to store images inside HTML document
            // using base-64 encoding
            f.HtmlOptions.IncludeImageInHtml = true;
            f.HtmlOptions.Title = "Simple text";

            // This property is necessary only for registered version


            f.OpenPdf(pathToPdf);

            if (f.PageCount > 0)
            {
                int result = f.ToHtml(pathToHtml);

                //Show HTML document in browser
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(pathToHtml);
                }
            }
        }
Example #10
0
        static void Main(string[] args)
        {
            string pdfFile  = @"..\..\..\..\..\simple text.pdf";
            string htmlFile = Path.ChangeExtension(pdfFile, ".htm");

            // Convert PDF file to HTML file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // Path (must exist) to a directory to store images after converting. Notice also to the property "ImageSubFolder".
            f.HtmlOptions.ImageFolder = Path.GetDirectoryName(pdfFile);
            // A folder (will be created by the component) without any drive letters, only the folder as "myfolder".
            f.HtmlOptions.ImageSubFolder = String.Format("{0}_images", Path.GetFileNameWithoutExtension(pdfFile));
            // We recommend to use PNG type for storing images.
            f.HtmlOptions.ImageType = PdfFocus.CHtmlOptions.eHtmlImageType.Png;
            // How to store images: Inside HTML document as base64 images or as linked separate image files.
            f.HtmlOptions.IncludeImageInHtml = false;
            // Set <title>...</title>
            f.HtmlOptions.Title = "Simple text";

            // After purchasing the license, please insert your serial number here to activate the component:
            //f.Serial = "123456789";

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                int result = f.ToHtml(htmlFile);

                // Show resulted HTML document in a browser.
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(htmlFile);
                }
            }
        }
Example #11
0
        static void Main(string[] args)
        {
            // Here you will find various ways to store images
            string pdfFile  = @"..\..\..\..\..\simple text.pdf";
            string htmlFile = Path.ChangeExtension(pdfFile, ".htm");

            // Convert PDF file to HTML file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // Way 1: Images will be stored as physical PNG files in: ImageFolder + ImageSubFolder.
            // For example: "d:\" + "special folder" = "d:\special folder\"

            /*
             * f.HtmlOptions.ImageFolder = @"d:\";
             * f.HtmlOptions.ImageSubFolder = "special folder";
             * f.HtmlOptions.ImageType = PdfFocus.CHtmlOptions.eHtmlImageType.Png;
             */

            // Way 2: Images will be stored as PNG files in the same directory with HTML file.
            // All images on each page will be combined in a single image.

            /*
             * f.HtmlOptions.ImageFolder = Path.GetDirectoryName(pdfFile);
             * f.HtmlOptions.ImageType = PdfFocus.CHtmlOptions.eHtmlImageType.Png;
             * f.HtmlOptions.ImageSubFolder = "";
             * f.HtmlOptions.CombineImages = true;
             */

            // Way 3: Images will be stored as Jpeg files in a special folder "my images".
            // Images will have name "picture100.jpg", "picture101.jpg" .. "pictureN.jpg".

            // Let's set the quality for jpeg images to 95 percents.
            f.HtmlOptions.ImageFolder    = Path.GetDirectoryName(pdfFile);
            f.HtmlOptions.ImageType      = PdfFocus.CHtmlOptions.eHtmlImageType.Jpeg;
            f.HtmlOptions.JpegQuality    = 95;
            f.HtmlOptions.ImageSubFolder = "my images";
            f.HtmlOptions.ImageFileName  = "picture";
            f.HtmlOptions.ImageNumStart  = 100;
            f.HtmlOptions.CombineImages  = false;

            // Way 4: Images will be stored inside HTML document as base64 images.

            /*
             * f.HtmlOptions.IncludeImageInHtml = true;
             */

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                int result = f.ToHtml(htmlFile);

                // Show resulted HTML document in a browser.
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(htmlFile);
                }
            }
        }
Example #12
0
        static void Main(string[] args)
        {
            // Here we'll show you two modes of converting PDF to HTML:
            // PDF Focus .Net offers you the Fixed and Flowing modes by your choice.

            // HTML-Fixed (default) is better to use for rendering, because it completely
            // repeats the PDF layout with the structure of pages.
            // The markup of such documents is very complex and have a lot of tags styled by (x,y) coords.

            // HTML-Flowing is better for further processing by a human: editing and combining.
            // The markup of such documents is much simple inside and has the flowing structure.
            // It's very simple for understanding by a human.
            // But the resulting HTML document doesn't look exactly the same as input PDF pixel by pixel.

            string pdfFile         = @"..\..\License.pdf";
            string htmlFileFixed   = "Fixed.html";
            string htmlFileFlowing = "Flowing.html";

            // Convert PDF file to HTML (Fixed and Flowing) file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // After purchasing the license, please insert your serial number here to activate the component:
            //f.Serial = "XXXXXXXXXXX";

            // How to store images: Inside HTML document as base64 images or as linked separate image files.
            f.HtmlOptions.IncludeImageInHtml = true;

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                // The HTML-Fixed mode.
                f.HtmlOptions.Title      = "Fixed";
                f.HtmlOptions.RenderMode = PdfFocus.CHtmlOptions.eHtmlRenderMode.Fixed;
                if (f.ToHtml(htmlFileFixed) == 0)
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(htmlFileFixed)
                    {
                        UseShellExecute = true
                    });
                }

                // The HTML-Flowing mode.
                f.HtmlOptions.Title      = "Flowing";
                f.HtmlOptions.RenderMode = PdfFocus.CHtmlOptions.eHtmlRenderMode.Flowing;
                // Switch off character scaling and spacing to prevent
                // adding of extra tags dividing the text by parts.
                f.HtmlOptions.KeepCharScaleAndSpacing = false;

                if (f.ToHtml(htmlFileFlowing) == 0)
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(htmlFileFlowing)
                    {
                        UseShellExecute = true
                    });
                }
            }
        }
Example #13
0
        public static void ConvertToExcel(object targ)
        {
            TArgument targum  = (TArgument)targ;
            string    pdfFile = targum.PdfFile;
            int       page    = targum.PageNumber;

            string excelFile = Path.GetFileNameWithoutExtension(pdfFile) + ".xls";

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // 'true' = Convert all data to spreadsheet (tabular and even textual).
            // 'false' = Skip textual data and convert only tabular (tables) data.
            f.ExcelOptions.ConvertNonTabularDataToSpreadsheet = true;

            // 'true'  = Preserve original page layout.
            // 'false' = Place tables before text.
            f.ExcelOptions.PreservePageLayout = true;

            // The information includes the names for the culture, the writing system,
            // the calendar used, the sort order of strings, and formatting for dates and numbers.
            System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");
            ci.NumberFormat.NumberDecimalSeparator = ",";
            ci.NumberFormat.NumberGroupSeparator   = ".";
            f.ExcelOptions.CultureInfo             = ci;

            f.OpenPdf(pdfFile);

            bool done = false;

            if (f.PageCount > 0)
            {
                if (page >= f.PageCount)
                {
                    page = 1;
                }

                if (f.ToExcel(excelFile, page, page) == 0)
                {
                    done = true;
                }
                f.ClosePdf();
            }

            if (done)
            {
                Console.WriteLine("{0}\t - Done!", Path.GetFileName(pdfFile));
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(excelFile)
                {
                    UseShellExecute = true
                });
            }
            else
            {
                Console.WriteLine("{0}\t - Error!", Path.GetFileName(pdfFile));
            }
        }
        private void btnPDF2Html_Click(object sender, EventArgs e) // PDF convert to Html Function
        {
            SautinSoft.PdfFocus Html = new SautinSoft.PdfFocus();  // 呼叫SautinSoft中的Html Convert Function
            Html.OpenPdf(@"C:\Users\施宗佑\OneDrive\桌面\期末報告 - 物件導向程式設計\測試用文檔\Graph.pdf");

            if (Html.PageCount > 0)
            {
                int result = Html.ToHtml(@"C:\Users\施宗佑\OneDrive\桌面\期末報告 - 物件導向程式設計\NewGraph.html");
            }
        }
Example #15
0
        /// <summary>
        /// Converts PDF to DOCX, RTF, HTML, Text with OCR engine.
        /// </summary>
        public void ConvertPdfToAllWithOCR(string pdfPath)
        {
            // To perform OCR we'll use free OCR library by Nicomsoft.
            // https://www.nicomsoft.com/products/ocr/download/
            // The library is freeware and can be used in commercial application.
            // Also you have to insert this key:  AB2A4DD5FF2A.
            NsOCR = new NSOCRLib.NSOCRClass();
            NsOCR.Engine_SetLicenseKey("AB2A4DD5FF2A"); //required for licensed version only
            NsOCR.Engine_InitializeAdvanced(out CfgObj, out OcrObj, out ImgObj);

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            f.OCROptions.Method += PerformOCRNicomsoft;
            f.OCROptions.Mode    = PdfFocus.COCROptions.eOCRMode.AllImages;
            f.WordOptions.KeepCharScaleAndSpacing = false;

            string pdfFile = pdfPath;
            string outFile = String.Empty;

            f.OpenPdf(pdfFile);
            if (f.PageCount > 0)
            {
                // To Docx.
                outFile = "Result.docx";
                f.WordOptions.Format = PdfFocus.CWordOptions.eWordDocument.Docx;
                if (f.ToWord(outFile) == 0)
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                    {
                        UseShellExecute = true
                    });
                }

                // To HTML.
                outFile = "Result.html";
                f.HtmlOptions.KeepCharScaleAndSpacing = false;
                if (f.ToHtml(outFile) == 0)
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outFile)
                    {
                        UseShellExecute = true
                    });
                }
            }
            else
            {
                Console.WriteLine("Error: {0}!", f.Exception.Message);
                Console.ReadLine();
            }
        }
        private void btnConvertJPG_Click(object sender, EventArgs e) // PDF convert to Image Function
        {
            SautinSoft.PdfFocus JPG = new SautinSoft.PdfFocus();     // 呼叫SautinSoft中的Image Convert Function
            JPG.OpenPdf(textBox1.Text);

            if (JPG.PageCount > 0)
            {
                JPG.ImageOptions.Dpi         = 200;
                JPG.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
                for (int page = 1; page <= JPG.PageCount; page++)
                {
                    JPG.ToImage(textBox1.Text + "page" + page + ".jpg", page);
                }
            }
        }
Example #17
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (file.HasFile)
            {
                try
                {
                    if (file.PostedFile.FileName.Length == 0 || file.FileBytes.Length == 0)
                    {
                        Result.Text = "Please select PDF file at first!";
                        return;
                    }
                    byte[] rtf = null;

                    SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
                    f.OpenPdf(file.FileBytes);

                    if (f.PageCount > 0)
                    {
                        //Let's whole PDF document to Word (RTF)
                        f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Rtf;

                        // You may also set an output format to Docx.
                        //f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Docx;
                        rtf = f.ToWord();
                    }

                    //show Word/rtf
                    if (rtf != null)
                    {
                        ShowResult(rtf, "Result.rtf", "application/msword");
                    }
                    else
                    {
                        Result.Text = "Converting failed!";
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.Message);
                }
            }
            else
            {
                Result.Text = "Please choose a file to upload!";
            }
        }
Example #18
0
        static void Main(string[] args)
        {
            //converte pdf em imagem
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            f.OpenPdf(@"D:\Projetos\OCR_Demo\Resultado\PDF.pdf");

            if (f.PageCount > 0)
            {
                f.ImageOptions.Dpi = 300;
                f.ToMultipageTiff(@"D:\Projetos\OCR_Demo\Resultado\imagem\PDF.tiff");
            }

            ConvertTiffToJpeg(@"D:\Projetos\OCR_Demo\Resultado\imagem\PDF.tiff");

            var files = Directory.GetFiles(@"D:\Projetos\OCR_Demo\Resultado\imagem\").Where(x => x.EndsWith("jpg"));

            StringBuilder stringBuilder = new StringBuilder();

            foreach (var file in files)
            {
                try
                {
                    using (var engine = new TesseractEngine(@"tessdata", "por", EngineMode.Default))
                    {
                        using (var img = Pix.LoadFromFile(file))
                        {
                            using (var page = engine.Process(img))
                            {
                                var texto = page.GetText();
                                stringBuilder.Append(texto);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Erro {0}", ex.Message);
                }
                finally
                {
                }
            }
            string filePath = @"D:\Projetos\OCR_Demo\Resultado\textos\teste.txt";

            File.WriteAllText(filePath, stringBuilder.ToString());
        }
Example #19
0
        public static void ConvertToExcel(object targ)
        {
            TArgument targum  = (TArgument)targ;
            string    pdfFile = targum.PdfFile;
            int       page    = targum.PageNumber;

            string excelFile = Path.ChangeExtension(pdfFile, ".xls");

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // 'true' = Convert all data to spreadsheet (tabular and even textual).
            // 'false' = Skip textual data and convert only tabular (tables) data.
            f.ExcelOptions.ConvertNonTabularDataToSpreadsheet = true;

            // 'true'  = Preserve original page layout.
            // 'false' = Place tables before text.
            f.ExcelOptions.PreservePageLayout = true;

            f.OpenPdf(pdfFile);

            bool done = false;

            if (f.PageCount > 0)
            {
                if (page >= f.PageCount)
                {
                    page = 1;
                }

                if (f.ToExcel(excelFile, page, page) == 0)
                {
                    done = true;
                }
                f.ClosePdf();
            }

            if (done)
            {
                Console.WriteLine("{0}\t - Done!", Path.GetFileName(pdfFile));
            }
            else
            {
                Console.WriteLine("{0}\t - Error!", Path.GetFileName(pdfFile));
            }
        }
Example #20
0
        public static void ConvertToPng(object targ)
        {
            TArgument targum  = (TArgument)targ;
            string    pdfFile = targum.PdfFile;
            int       page    = targum.PageNumber;

            string pngFile = Path.GetFileNameWithoutExtension(pdfFile) + ".png";

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
            f.ImageOptions.Dpi         = 300;

            f.OpenPdf(pdfFile);

            bool done = false;

            if (f.PageCount > 0)
            {
                if (page >= f.PageCount)
                {
                    page = 1;
                }

                if (f.ToImage(pngFile, page) == 0)
                {
                    done = true;
                }
                f.ClosePdf();
            }

            if (done)
            {
                Console.WriteLine("{0}\t - Done!", Path.GetFileName(pdfFile));
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pngFile)
                {
                    UseShellExecute = true
                });
            }
            else
            {
                Console.WriteLine("{0}\t - Error!", Path.GetFileName(pdfFile));
            }
        }
Example #21
0
        static void Main(string[] args)
        {
            string pdfFile  = @"..\..\simple text.pdf";
            string htmlFile = "Result.html";

            // Convert PDF file to HTML file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // After purchasing the license, please insert your serial number here to activate the component:
            //f.Serial = "XXXXXXXXXXX";

            // Path (must exist) to a directory to store images after converting. Notice also to the property "ImageSubFolder".
            f.HtmlOptions.ImageFolder = Path.GetDirectoryName(htmlFile);

            // A folder (will be created by the component) without any drive letters, only the folder as "myfolder".
            f.HtmlOptions.ImageSubFolder = String.Format("{0}_images", Path.GetFileNameWithoutExtension(pdfFile));

            // Auto - the same image format as in the source PDF;
            // 'Jpeg' to make the document size less;
            // 'PNG' to keep the highest quality, but the highest size too.
            f.EmbeddedImagesFormat = PdfFocus.eImageFormat.Auto;

            // How to store images: Inside HTML document as base64 images or as linked separate image files.
            f.HtmlOptions.IncludeImageInHtml = false;

            // Set <title>...</title>
            f.HtmlOptions.Title = String.Format("This HTML was converted from {0}.", Path.GetFileName(pdfFile));

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                int res = f.ToHtml(htmlFile);

                // Open the result for demonstration purposes.
                if (res == 0)
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(htmlFile)
                    {
                        UseShellExecute = true
                    });
                }
            }
        }
Example #22
0
        public static void ConvertToWord(object targ)
        {
            TArgument targum  = (TArgument)targ;
            string    pdfFile = targum.PdfFile;
            int       page    = targum.PageNumber;

            string docxFile = Path.GetFileNameWithoutExtension(pdfFile) + ".docx";

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            f.WordOptions.Format     = PdfFocus.CWordOptions.eWordDocument.Docx;
            f.WordOptions.RenderMode = PdfFocus.CWordOptions.eRenderMode.Flowing;

            f.OpenPdf(pdfFile);

            bool done = false;

            if (f.PageCount > 0)
            {
                if (page >= f.PageCount)
                {
                    page = 1;
                }

                if (f.ToWord(docxFile, page, page) == 0)
                {
                    done = true;
                }
                f.ClosePdf();
            }

            if (done)
            {
                Console.WriteLine("{0}\t - Done!", Path.GetFileName(pdfFile));
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(docxFile)
                {
                    UseShellExecute = true
                });
            }
            else
            {
                Console.WriteLine("{0}\t - Error!", Path.GetFileName(pdfFile));
            }
        }
Example #23
0
        public static void ConvertToXml(object targ)
        {
            TArgument targum  = (TArgument)targ;
            string    pdfFile = targum.PdfFile;
            int       page    = targum.PageNumber;

            string xmlFile = Path.GetFileNameWithoutExtension(pdfFile) + ".xml";

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // Let's convert all data (textual and tabular) to XML.
            f.XmlOptions.ConvertNonTabularDataToSpreadsheet = true;

            f.OpenPdf(pdfFile);

            bool done = false;

            if (f.PageCount > 0)
            {
                if (page >= f.PageCount)
                {
                    page = 1;
                }

                if (f.ToXml(xmlFile, page, page) == 0)
                {
                    done = true;
                }
                f.ClosePdf();
            }

            if (done)
            {
                Console.WriteLine("{0}\t - Done!", Path.GetFileName(pdfFile));
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(xmlFile)
                {
                    UseShellExecute = true
                });
            }
            else
            {
                Console.WriteLine("{0}\t - Error!", Path.GetFileName(pdfFile));
            }
        }
Example #24
0
        public override void convertToWord(string path, string tempFolder)
        {
            nameDocFile     = Path.GetFileNameWithoutExtension(path) + extension;
            convertFileName = nameDocFile;
            string pathDocFile = Path.Combine(tempFolder, nameDocFile);

            pathWordFile = pathDocFile;
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            if (File.Exists(pathDocFile))
            {
                File.Delete(pathDocFile);
            }
            f.OpenPdf(path);
            if (f.PageCount > 0)
            {
                f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Docx;
                f.ToWord(pathDocFile);
            }
        }
Example #25
0
        public static void ConvertToHtml(object targ)
        {
            TArgument targum  = (TArgument)targ;
            string    pdfFile = targum.PdfFile;
            int       page    = targum.PageNumber;

            string htmlFile = targum.HtmlFile;

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            f.EmbeddedImagesFormat           = PdfFocus.eImageFormat.Auto;
            f.HtmlOptions.IncludeImageInHtml = false;
            f.HtmlOptions.ImageSubFolder     = String.Format("{0}_images", Path.GetFileNameWithoutExtension(pdfFile));
            f.HtmlOptions.Title         = String.Format("This document was produced from {0}.", Path.GetFileName(pdfFile));
            f.HtmlOptions.ImageFileName = "picture";

            f.OpenPdf(pdfFile);

            bool done = false;

            if (f.PageCount > 0)
            {
                if (page >= f.PageCount)
                {
                    page = 1;
                }

                if (f.ToHtml(htmlFile, page, page) == 0)
                {
                    done = true;
                }
                f.ClosePdf();
            }

            if (done)
            {
                Console.WriteLine("{0}\t - Done!", Path.GetFileName(pdfFile));
            }
            else
            {
                Console.WriteLine("{0}\t - Error!", Path.GetFileName(pdfFile));
            }
        }
Example #26
0
        public static void ConvertToText(object targ)
        {
            TArgument targum  = (TArgument)targ;
            string    pdfFile = targum.PdfFile;
            int       page    = targum.PageNumber;

            string textFile = Path.GetFileNameWithoutExtension(pdfFile) + ".txt";

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            f.WordOptions.ShowInvisibleText = true;

            f.OpenPdf(pdfFile);

            bool done = false;

            if (f.PageCount > 0)
            {
                if (page >= f.PageCount)
                {
                    page = 1;
                }

                if (f.ToText(textFile, page, page) == 0)
                {
                    done = true;
                }
                f.ClosePdf();
            }

            if (done)
            {
                Console.WriteLine("{0}\t - Done!", Path.GetFileName(pdfFile));
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(textFile)
                {
                    UseShellExecute = true
                });
            }
            else
            {
                Console.WriteLine("{0}\t - Error!", Path.GetFileName(pdfFile));
            }
        }
Example #27
0
        public static void ConvertToHtml(object targ)
        {
            TArgument targum  = (TArgument)targ;
            string    pdfFile = targum.PdfFile;
            int       page    = targum.PageNumber;

            string htmlFile = Path.ChangeExtension(pdfFile, ".html");

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            f.HtmlOptions.ImageType          = PdfFocus.CHtmlOptions.eHtmlImageType.Png;
            f.HtmlOptions.IncludeImageInHtml = false;
            f.HtmlOptions.ImageSubFolder     = String.Format("{0}_images", Path.GetFileNameWithoutExtension(pdfFile));
            f.HtmlOptions.ImageFileName      = "pict";

            f.OpenPdf(pdfFile);

            bool done = false;

            if (f.PageCount > 0)
            {
                if (page >= f.PageCount)
                {
                    page = 1;
                }

                if (f.ToHtml(htmlFile, page, page) == 0)
                {
                    done = true;
                }
                f.ClosePdf();
            }

            if (done)
            {
                Console.WriteLine("{0}\t - Done!", Path.GetFileName(pdfFile));
            }
            else
            {
                Console.WriteLine("{0}\t - Error!", Path.GetFileName(pdfFile));
            }
        }
        static void Main(string[] args)
        {
            string pathToPdf  = @"d:\simple text.pdf";
            string pathToWord = @"d:\result.doc";

            //Convert PDF file to Word file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            f.OpenPdf(pathToPdf);

            if (f.PageCount > 0)
            {
                int result = f.ToWord(pathToWord);

                //Show Word document
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(pathToWord);
                }
            }
        }
Example #29
0
        public static void ConvertToText(object targ)
        {
            TArgument targum  = (TArgument)targ;
            string    pdfFile = targum.PdfFile;
            int       page    = targum.PageNumber;

            string textFile = Path.ChangeExtension(pdfFile, ".txt");

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            f.WordOptions.ShowInvisibleText = true;

            f.OpenPdf(pdfFile);

            bool done = false;

            if (f.PageCount > 0)
            {
                if (page >= f.PageCount)
                {
                    page = 1;
                }

                if (f.ToText(textFile, page, page) == 0)
                {
                    done = true;
                }
                f.ClosePdf();
            }

            if (done)
            {
                Console.WriteLine("{0}\t - Done!", Path.GetFileName(pdfFile));
            }
            else
            {
                Console.WriteLine("{0}\t - Error!", Path.GetFileName(pdfFile));
            }
        }
        static void Main(string[] args)
        {
            //Convert PDF file to Multipage TIFF file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            // You may download the latest version of SDK here:
            // www.sautinsoft.com/products/pdf-focus/download.php


            string pdfPath  = @"d:\Tempos\table.pdf";
            string tiffPath = @"d:\Tempos\table.tiff";

            f.OpenPdf(pdfPath);

            if (f.PageCount > 0)
            {
                f.ImageOptions.Dpi = 120;
                if (f.ToMultipageTiff(tiffPath) == 0)
                {
                    System.Diagnostics.Process.Start(tiffPath);
                }
            }
        }