Esempio n. 1
0
        private static void ConvertPdfToRtf()
        {
            string pdfFile  = @"..\..\text and graphics.pdf";
            string wordFile = "Result.rtf";

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

            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Rtf;
                int result = f.ToWord(wordFile);

                // Show the produced result.
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(wordFile)
                    {
                        UseShellExecute = true
                    });
                }
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string pdfPath   = @"..\..\simple text.pdf";
            string imagePath = "Result.gif";

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";
            f.OpenPdf(pdfPath);

            if (f.PageCount > 0)
            {
                //Set "GIF" format for image
                f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Gif;

                //Convert 1st page from PDF to image file
                if (f.ToImage(imagePath, 1) == 0)
                {
                    // 0 - converting successfully
                    // 2 - can't create output file, check the output path
                    // 3 - converting failed
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(imagePath)
                    {
                        UseShellExecute = true
                    });
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Convierte una imagen pdf a una multi tiff
        /// </summary>
        /// <param name="pdfPath">Ruta del archivo origen </param>
        /// <param name="tiffPath">Ruta del archivo destino con extencion tiff</param>
        public static int ConvertirimagenPDFaTIFF(string pdfPath, string tiffPath)
        {
            //modifica William Cicua; 05/05/2016; se crea parametro que activa u desactiva la
            // conversion a .tif
            GestorDocumentalEnt db = new GestorDocumentalEnt();

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            f.Serial = "10160711675";   //Serial develop
            //f.Serial = "10160735830"; //Serial Server
            f.OpenPdf(pdfPath);
            if (f.PageCount > 0)
            {
                f.ImageOptions.Dpi = 200;
                var    algo       = f.PageCount;
                string tifactivo1 = db.Parametros.Where(c => c.codigo == "CONVERSION_A_TIFF_ACTIVO").First().valor;

                int tifactivo = Convert.ToInt32(tifactivo1);
                if (tifactivo == 1)
                {
                    if (f.ToMultipageTiff(tiffPath, System.Drawing.Imaging.EncoderValue.CompressionCCITT4) == 0)
                    {
                        //System.Diagnostics.Process.Start(tiffPath);
                    }
                }
            }
            return(f.PageCount);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            string pathToPdf  = @"..\..\..\..\..\simple text.pdf";
            string pathToWord = Path.ChangeExtension(pathToPdf, ".rtf");

            // Convert diapason of PDF pages to a Word file.
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            // this property is necessary only for registered version.
            //f.Serial = "XXXXXXXXXXX";

            f.OpenPdf(pathToPdf);

            if (f.PageCount > 0)
            {
                // You may set an output format to docx or rtf.
                f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Rtf;

                // Convert only pages 2 - 4 to Word.
                int result = f.ToWord(pathToWord, 2, 4);

                // Show Word document
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(pathToWord);
                }
            }
        }
        public void Converter(string fopen, string fsave)
        {
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            f.OpenPdf(fopen);
            //f.ToWord(textBox2.Text);

            if (f.PageCount > 0)
            {
                // You may choose output format between Docx and Rtf.
                f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Docx;

                int result = f.ToWord(fsave);


                // Show the resulting Word document.
                if (result == 0)
                {
                    //Form1 main = new Form1();

                    //  main.popup();

                    //System.Diagnostics.Process.Start(textBox2.Text);
                    MessageBox.Show("Conversion is Completed!");
                }
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            //Convert PDF files to 300-dpi TIFF files
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            string[] pdfFiles        = Directory.GetFiles(@"..\..\..\..\..\", "*.pdf");
            string   folderWithTiffs = @"..\..\..\..\..\";

            foreach (string pdffile in pdfFiles)
            {
                f.OpenPdf(pdffile);

                if (f.PageCount > 0)
                {
                    //Set image format: TIFF, 300 dpi
                    f.ImageOptions.Dpi         = 300;
                    f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;

                    //Save all pages to tiff files with 300 dpi
                    f.ToImage(folderWithTiffs, Path.GetFileNameWithoutExtension(pdffile));
                }
                f.ClosePdf();
            }
            //Show folder with tiffs
            System.Diagnostics.Process.Start(folderWithTiffs);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            //How to convert PDF to 1-bit black and white PNG
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            string pdfPath   = @"..\..\..\..\..\simple text.pdf";
            string imagePath = Path.ChangeExtension(pdfPath, ".png");

            f.OpenPdf(pdfPath);

            if (f.PageCount > 0)
            {
                //save 1st page to png file, 120 dpi
                f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
                f.ImageOptions.Dpi         = 120;
                //Make "Black and White 1-bit indexed" image
                f.ImageOptions.ColorDepth = SautinSoft.PdfFocus.CImageOptions.eColorDepth.BlackWhite1bpp;

                if (f.ToImage(imagePath, 1) == 0)
                {
                    // 0 - converting successfully
                    // 2 - can't create output file, check the output path
                    // 3 - converting failed
                    System.Diagnostics.Process.Start(imagePath);
                }
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            //Convert custom PDF page to Image object
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            string pdfPath   = @"..\..\..\..\..\simple text.pdf";
            string imagePath = Path.ChangeExtension(pdfPath, ".png");

            f.OpenPdf(pdfPath);

            if (f.PageCount > 0)
            {
                //Let's convert 1st page into System.Drawing.Image object, 120 dpi
                f.ImageOptions.Dpi = 120;
                System.Drawing.Image img = f.ToDrawingImage(1);

                //Save to file
                if (img != null)
                {
                    img.Save(imagePath);
                    System.Diagnostics.Process.Start(imagePath);
                }
            }
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            byte[] pdfBytes = File.ReadAllBytes(@"C:\Users\adit.shah\source\repos\aditshh\RTFToPDF\SampleFile\sampleWithImages.pdf");

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

            f.OpenPdf(pdfBytes);

            if (f.PageCount > 0)
            {
                byte[] word = f.ToWord();
                System.IO.File.WriteAllBytes(@"C:\Users\adit.shah\source\repos\aditshh\RTFToPDF\SampleFile\sampleWithImages_sautinSoft.rtf", word);

                f.HtmlOptions.IncludeImageInHtml = true;
                f.HtmlOptions.InlineCSS          = true;
                string html = f.ToHtml();

                System.IO.File.WriteAllText(@"C:\Users\adit.shah\source\repos\aditshh\RTFToPDF\SampleFile\sampleWithImages_sautinSoft.html", html);

                //Console.WriteLine(html);
                //Console.WriteLine("In base64 rtf: {0}", Convert.ToBase64String(word));

                string rez = GetText(@"C:\Users\adit.shah\source\repos\aditshh\RTFToPDF\SampleFile\sampleWithImages.pdf");
                System.IO.File.WriteAllText(@"C:\Users\adit.shah\source\repos\aditshh\RTFToPDF\SampleFile\sampleWithImages_iTextSharp.txt", rez);
                System.IO.File.WriteAllText(@"C:\Users\adit.shah\source\repos\aditshh\RTFToPDF\SampleFile\sampleWithImages_iTextSharp.rtf", rez);


                string rHTML = ConvertPdf(@"C:\Users\adit.shah\source\repos\aditshh\RTFToPDF\SampleFile\sampleWithImages.pdf", @"C:\Users\adit.shah\source\repos\aditshh\RTFToPDF\SampleFile\sampleWithImages_iTextSharp.html");


                //string spireReturn = SpirePDF(@"C:\Users\adit.shah\source\repos\aditshh\RTFToPDF\SampleFile\sampleWithImages.pdf", @"C:\Users\adit.shah\source\repos\aditshh\RTFToPDF\SampleFile\sampleWithImages_SpirePDF.html");
                Console.ReadLine();
            }
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            string filePath = @"c:\users\taylan\desktop\MgzSozlesme1.pdf";

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

            f.OpenPdf(filePath);

            if (f.PageCount > 0)
            {
                //Set image properties: Jpeg, 200 dpi

                f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;

                f.ImageOptions.Dpi = 200;

                //Save all PDF pages as page1.jpg, page2.jpg ... pageN.jpg

                //f.ToImage(@"c:\users\taylan\desktop\test2.jpg", 1);

                var image = f.ToDrawingImage(1);

                Bitmap bMap = new Bitmap(image);

                IBarcodeReader reader = new BarcodeReader();
                var            result = reader.Decode(bMap);

                DmtxImageDecoder decoder = new DmtxImageDecoder();

                List <string> oList = decoder.DecodeImage(bMap);

                int count = oList.Count;
            }
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            string pathToPdf  = @"..\..\Potato Beetle.pdf";
            string pathToWord = "Result.rtf";

            // Convert diapason of PDF pages to a Word file.
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            // this property is necessary only for registered version.
            //f.Serial = "XXXXXXXXXXX";

            f.OpenPdf(pathToPdf);

            if (f.PageCount > 0)
            {
                // You may set an output format to docx or rtf.
                f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Rtf;

                // Convert only pages 2 - 4 to Word.
                int result = f.ToWord(pathToWord, 2, 4);

                // Show Word document
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pathToWord)
                    {
                        UseShellExecute = true
                    });
                }
            }
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            string pdfPath   = @"..\..\simple text.pdf";
            string imagePath = "Result.png";

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";
            f.OpenPdf(pdfPath);

            if (f.PageCount > 0)
            {
                //In most cases we recommend to set 200 dpi to decrease the image size and converting speed
                //Now set 300 dpi - very high quality
                f.ImageOptions.Dpi = 300;

                //Convert 1st page from PDF to image file
                if (f.ToImage(imagePath, 1) == 0)
                {
                    // 0 - converting successfully
                    // 2 - can't create output file, check the output path
                    // 3 - converting failed
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(imagePath)
                    {
                        UseShellExecute = true
                    });
                }
            }
        }
Esempio n. 13
0
            public void Convert(string pdfLocation, string wordLocation)
            {
                // Convert PDF file to DOCX file 
                SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

                f.OpenPdf(pdfLocation);

                if (f.PageCount > 0)
                {
                    // You may choose output format between Docx and Rtf. 
                    f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Docx;

                    int result = f.ToWord(wordLocation);

                    // Show the resulting Word document. 
                    try
                    {
                        if (result == 0)
                        {
                            System.Diagnostics.Process.Start(wordLocation);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message, ex.InnerException);
                    }
                }
            }
Esempio n. 14
0
        private static void ConvertPdfToDocxBytes()
        {
            string pdfFile = @"..\..\..\..\..\simple text.pdf";

            // Assume that we already have a PDF document as array of bytes.
            byte[] pdf  = File.ReadAllBytes(pdfFile);
            byte[] docx = null;

            // Convert PDF to word in memory
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            f.OpenPdf(pdf);

            if (f.PageCount > 0)
            {
                // Convert pdf to word in memory.
                docx = f.ToWord();

                // Save word document to a file only for demonstration purposes.
                if (docx != null)
                {
                    //3. Save to DOCX document to a file for demonstration purposes.
                    string wordFile = Path.ChangeExtension(pdfFile, ".docx");
                    File.WriteAllBytes(wordFile, docx);
                    System.Diagnostics.Process.Start(wordFile);
                }
            }
        }
Esempio n. 15
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.PostedFile.FileName.Length == 0 || FileUpload1.FileBytes.Length == 0)
        {
            TextBox1.Text = "Please select PDF file at first!";
            return;
        }

        SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
        //this property is necessary only for registered version
        //f.Serial = "XXXXXXXXXXX";
        f.OpenPdf(FileUpload1.FileBytes);

        if (f.PageCount > 0)
        {
            //Convert whole PDF to Text (extract text from PDF)
            string text = f.ToText();

            //show text
            TextBox1.Text = text;
        }
        else
        {
            TextBox1.Text = "Extracting failed!";
        }
    }
Esempio n. 16
0
        static void Main(string[] args)
        {
            // Activation of PDF Focus .Net after purchasing
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // Place your serial number here.
            // You will get an own serial number after purchasing the license.
            // If have any questions, email us to [email protected] or ask at online chat http://www.sautinsoft.com.
            f.Serial = "1234567890";

            string pdfPath  = @"..\..\..\..\simple text.pdf";
            string tiffPath = Path.ChangeExtension(pdfPath, ".tiff");

            // Open PDF
            f.OpenPdf(pdfPath);

            if (f.PageCount > 0)
            {
                // 0 - converting successfully
                // 2 - can't create output file, check the output path
                // 3 - converting failed
                f.ImageOptions.Dpi = 120;
                if (f.ToMultipageTiff(tiffPath) == 0)
                {
                    System.Diagnostics.Process.Start(tiffPath);
                }
            }
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            string pathToPdf = @"D:\Nalco Global Automation Coding Standard and Style Guide 1.0.pdf";
            string pathToXml = Path.ChangeExtension(pathToPdf, ".xml");

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

            // This property is necessary only for registered version.
            //f.Serial = "XXXXXXXXXXX";

            // Let's convert only tables to XML and skip all textual data.
            f.XmlOptions.ConvertNonTabularDataToSpreadsheet = true;

            f.OpenPdf(pathToPdf);

            if (f.PageCount > 0)
            {
                int result = f.ToXml(pathToXml);

                //Show HTML document in browser
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(pathToXml);
                }
            }

            //SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //f.XmlOptions.ConvertNonTabularDataToSpreadsheet = true;
            //f.OpenPdf(@"d:\[STRAT-511] Associate Skills Groups with Departments - TeleTracking Technologies.pdf");
            //f.ToXml(@"d:\[STRAT-511] Associate Skills Groups with Departments - TeleTracking Technologies.xml");
        }
Esempio n. 18
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.PostedFile.FileName.Length == 0 || FileUpload1.FileBytes.Length == 0)
        {
            Result.Text = "Please select PDF file at first!";
            return;
        }
        byte[] rtf = null;

        SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
        //this property is necessary only for registered version
        //f.Serial = "XXXXXXXXXXX";
        f.OpenPdf(FileUpload1.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!";
        }
    }
Esempio n. 19
0
        static void Main(string[] args)
        {
            string pathToPdf = @"..\..\..\..\..\Table.pdf";
            string pathToXml = Path.ChangeExtension(pathToPdf, ".xml");

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

            // This property is necessary only for registered version.
            //f.Serial = "XXXXXXXXXXX";

            // Let's convert only tables to XML and skip all textual data.
            f.XmlOptions.ConvertNonTabularDataToSpreadsheet = false;

            f.OpenPdf(pathToPdf);

            if (f.PageCount > 0)
            {
                int result = f.ToXml(pathToXml);

                //Show HTML document in browser
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(pathToXml);
                }
            }
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            //Convert PDF into specified Image height & width
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            // Set initial values
            string pdfPath     = @"..\..\..\..\..\simple text.pdf";
            string imageFolder = Path.GetDirectoryName(pdfPath);
            int    width       = 1600; // Width in Px
            int    height      = 1900; // Height in Px

            //Set image options
            f.ImageOptions.ImageFormat = ImageFormat.Png;
            f.ImageOptions.Resize(new Size {
                Width = width, Height = height
            }, false);


            f.OpenPdf(pdfPath);
            if (f.PageCount > 0)
            {
                // Convert all pages to PNG images
                f.ToImage(imageFolder, "Page");

                //Show image
                System.Diagnostics.Process.Start(imageFolder);
            }
        }
Esempio n. 21
0
        private static void ConvertPdfToRtfStream()
        {
            string       pdfFile   = @"..\..\..\..\..\simple text.pdf";
            MemoryStream rtfStream = new MemoryStream();

            // Convert PDF to word in memory
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";


            // Assume that we already have a PDF document as stream.
            using (FileStream pdfStream = new FileStream(pdfFile, FileMode.Open, FileAccess.Read))
            {
                f.OpenPdf(pdfStream);

                if (f.PageCount > 0)
                {
                    f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Rtf;
                    int res = f.ToWord(rtfStream);

                    // Save rtfStream to a file for demonstration purposes.
                    if (res == 0)
                    {
                        string rtfFile = Path.ChangeExtension(pdfFile, ".rtf");
                        File.WriteAllBytes(rtfFile, rtfStream.ToArray());
                        System.Diagnostics.Process.Start(rtfFile);
                    }
                }
            }
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            string pdfPath   = @"..\..\..\..\..\simple text.pdf";
            string imagePath = Path.ChangeExtension(pdfPath, ".png");

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";
            f.OpenPdf(pdfPath);

            if (f.PageCount > 0)
            {
                //Set color depth: Grayscale 24 bit
                f.ImageOptions.ColorDepth = SautinSoft.PdfFocus.CImageOptions.eColorDepth.Grayscale24bpp;

                //Convert 1st page from PDF to image file
                if (f.ToImage(imagePath, 1) == 0)
                {
                    // 0 - converting successfully
                    // 2 - can't create output file, check the output path
                    // 3 - converting failed
                    System.Diagnostics.Process.Start(imagePath);
                }
            }
        }
Esempio n. 23
0
        public ActionResult getData(string category, string name, string equation, HttpPostedFileBase file)
        {
            string fileName = category + name;
            string path = "";
            string pathOfFolder = "";
            p = new Picture(category, name, equation, file);
            Vuforia v;
            if (file.ContentLength > 0)
            {

                path = Path.Combine(Server.MapPath("~/Content/images"), fileName);
                pathOfFolder = Server.MapPath("~/Content/images") + "\\";
                file.SaveAs(path);
            }

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

            if (f.PageCount > 0)
            {
                f.ImageOptions.Dpi = 300;
                f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;

                for (int page = 1; page <= f.PageCount; page++)
                {
                    f.ToImage(pathOfFolder + "MyPDFImage.jpg", page);
                }
            }

            return View("TargetSelection");
            //v = new Vuforia(fileName, path);
            //v.postTarget();
        }
Esempio n. 24
0
        static void Main(string[] args)
        {
            string pathToPdf = @"..\..\..\..\..\Table.pdf";
            string pathToXml = Path.ChangeExtension(pathToPdf, ".xml");

            byte[] pdf = File.ReadAllBytes(pathToPdf);
            string xml = null;

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

            // This property is necessary only for registered version.
            //f.Serial = "XXXXXXXXXXX";

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

            f.OpenPdf(pdf);

            if (f.PageCount > 0)
            {
                xml = f.ToXml();

                //Show XML document in browser
                if (!String.IsNullOrEmpty(xml))
                {
                    File.WriteAllText(pathToXml, xml);
                    System.Diagnostics.Process.Start(pathToXml);
                }
            }
        }
Esempio n. 25
0
    public static string getPageFromPDF(string pdfData, int index)
    {
        // Convert PDF 1st page to PNG file.
        SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

        // this property is necessary only for registered version.
        //f.Serial = "XXXXXXXXXXX";

        // pdfFileUrl = @"D:\Documents\Visual Studio 2012\WebSites\AllTest\Uploads\200206mockh3e_1307221909015679_1511051147042637.pdf";

        string imagePath = Path.ChangeExtension(pdfData, ".jpg");

        byte[] sPDFDecoded = Convert.FromBase64String(pdfData);

        // saving pdf
        // File.WriteAllBytes(@"D:\Documents\Visual Studio 2012\WebSites\AllTest\Uploads\pdf8.pdf", sPDFDecoded);

        // open pdfFileUrl
        // f.OpenPdf(pdfFileUrl);

        f.OpenPdf(sPDFDecoded);

        return(JsonConvert.SerializeObject(new PDFInfo()
        {
            total = f.PageCount, index = index
        }));
    }
Esempio n. 26
0
        static void Main(string[] args)
        {
            string pdfFile = @"..\..\..\..\..\simple text.pdf";

            // Assume that we already have PDF as byte array
            byte[] pdfBytes = File.ReadAllBytes(pdfFile);

            // Extract Text from PDF only from 1st page
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                // Convert only 1st page
                string textString = f.ToText(1, 1);

                // Save 'textString' to a file only for demonstration purposes.
                string textFile = Path.ChangeExtension(pdfFile, ".txt");
                File.WriteAllText(textFile, textString);
                System.Diagnostics.Process.Start(textFile);
            }
        }
Esempio n. 27
0
        static void Main(string[] args)
        {
            string remotePdfUrl = @"https://www.sautinsoft.net/samples/simple%20text.pdf";
            string pathToWord   = @"Result.docx";

            //Convert URL-PDF from Internet to a Word file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            Uri uri = new Uri(remotePdfUrl);

            f.OpenPdf(uri);

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

                //Show the resulting Word document
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pathToWord)
                    {
                        UseShellExecute = true
                    });
                }
            }
        }
Esempio n. 28
0
        private Bitmap[] PdfToImage(string pdfPath)
        {
            Log("Inizio conversione PDF -> Immagine");
            List <Bitmap> images = new List <Bitmap>();

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

            string jpegDir = System.IO.Path.GetDirectoryName(pdfPath);

            f.OpenPdf(pdfPath);

            if (f.PageCount > 0)
            {
                f.ImageOptions.ImageFormat = ImageFormat.Jpeg;
                f.ImageOptions.Dpi         = 300;
                f.ImageOptions.JpegQuality = 100;

                for (int page = 1; page <= f.PageCount; page++)
                {
                    byte[] imageData = f.ToImage(page);
                    var    ms        = new MemoryStream(imageData);
                    images.Add(new Bitmap(ms));
                    Log("Convertita immagine n°" + page);
                }
            }

            Log("Finita conversione PDF");

            return(images.ToArray());
        }
Esempio n. 29
0
        public ActionResult getData(string category, string name, string equation, HttpPostedFileBase file)
        {
            string fileName     = category + name;
            string path         = "";
            string pathOfFolder = "";

            p = new Picture(category, name, equation, file);
            Vuforia v;

            if (file.ContentLength > 0)
            {
                path         = Path.Combine(Server.MapPath("~/Content/images"), fileName);
                pathOfFolder = Server.MapPath("~/Content/images") + "\\";
                file.SaveAs(path);
            }

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

            if (f.PageCount > 0)
            {
                f.ImageOptions.Dpi         = 300;
                f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;

                for (int page = 1; page <= f.PageCount; page++)
                {
                    f.ToImage(pathOfFolder + "MyPDFImage.jpg", page);
                }
            }

            return(View("TargetSelection"));
            //v = new Vuforia(fileName, path);
            //v.postTarget();
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            string pdfFile  = @"..\..\Potato Beetle.pdf";
            string textFile = "Result.txt";

            //Extract Text from 2nd-3rd pages of PDF
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            f.OpenPdf(pdfFile);

            if (f.PageCount > 2)
            {
                //Convert only pages 2 - 3 to Text
                int result = f.ToText(textFile, 2, 3);

                //Show Text document
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(textFile)
                    {
                        UseShellExecute = true
                    });
                }
            }
        }
Esempio n. 31
0
        static void Main(string[] args)
        {
            string pdfFile  = @"..\..\text and graphics.pdf";
            string wordFile = "Result.docx";

            // Convert a PDF file to a Word file
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                // You may choose output format between Docx and Rtf.
                f.WordOptions.Format = SautinSoft.PdfFocus.CWordOptions.eWordDocument.Docx;

                int result = f.ToWord(wordFile);

                // Show the resulting Word document.
                if (result == 0)
                {
                    System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(wordFile)
                    {
                        UseShellExecute = true
                    });
                }
            }
        }
Esempio n. 32
0
        public void ExtractXml(string sourcePdfPath , bool considerNonTabular)
        {
            //string pathToPdf = @"..\..\..\..\..\Page58.pdf";
            string pathToXml = System.IO.Path.ChangeExtension(sourcePdfPath, ".xml");
            

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

            // This property is necessary only for registered version.
            //f.Serial = "XXXXXXXXXXX";

            // Let's convert only tables to XML and skip all textual data.
            f.XmlOptions.ConvertNonTabularDataToSpreadsheet = considerNonTabular;

            f.OpenPdf(sourcePdfPath);

            if (f.PageCount > 0)
            {
                int result = f.ToXml(pathToXml);

                //Show HTML document in browser
                //if (result == 0)
                //{
                //    System.Diagnostics.Process.Start(pathToXml);
                //}
            }
        }