Ejemplo n.º 1
0
        /// <summary>
        /// pdf生成xml
        /// </summary>
        /// <param name="pdfFile"></param>
        /// <returns></returns>
        public static bool PdfToXMLAsFiles(string pdfFile)
        {
            try
            {
                string pathToXml = Path.ChangeExtension(pdfFile, ".xml");
                // Convert PDF file to XML file.
                PdfFocus f = new 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(pdfFile);

                if (f.PageCount > 0)
                {
                    int result = f.ToXml(pathToXml);
                    if (result == 0)
                    {
                        //Show XML document in browser 选择直接打开
                        // Process.Start(new ProcessStartInfo(pathToXml) { UseShellExecute = true });
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            return(false);
        }
Ejemplo n.º 2
0
        private static Dictionary <string, string> GetFileContentsThroughSautin(string[] files)
        {
            Dictionary <string, string> contents = new Dictionary <string, string>();

            foreach (var file in files)
            {
                string content = string.Empty;

                PdfFocus f = new PdfFocus();
                f.XmlOptions.ConvertNonTabularDataToSpreadsheet = true;

                f.OpenPdf(file);

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

                contents.Add(file, content);
            }

            return(contents);
        }