static void Main(string[] args)
        {
            // Create Bytescout.PDFExtractor.AttachmentExtractor instance
            AttachmentExtractor extractor = new AttachmentExtractor();

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

            // Load sample PDF document
            extractor.LoadDocumentFromFile(@".\ZUGFeRD-invoice.pdf");

            // Extract the XML invoice that is stored as an attachment
            for (int i = 0; i < extractor.Count; i++)
            {
                Console.WriteLine("Saving XML invoice attachment: " + extractor.GetFileName(i));

                // Save file to current folder
                extractor.Save(i, extractor.GetFileName(i));

                Console.WriteLine("Done.");
            }

            // Cleanup
            extractor.Dispose();

            Console.WriteLine();
            Console.WriteLine("Press any key...");
            Console.ReadLine();
        }
Exemple #2
0
 private void ExtractAttachments(MergePart segment)
 {
     using (var extractor = new AttachmentExtractor())
     {
         extractor.PerformExtraction(segment.Info, segment.Filename);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            String inputFile = Server.MapPath(@"bin\attachments.pdf");

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

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

            // Load sample PDF document
            extractor.LoadDocumentFromFile(inputFile);

            Response.Clear();
            Response.ContentType = "text/html";

            for (int i = 0; i < extractor.Count; i++)
            {
                Response.Write("Saving attachment: " + extractor.GetFileName(i) + "<br>");
                //extractor.Save(i, extractor.GetFileName(i)); // you can save into temp folder or save to Stream object to avoid temp files
                Response.Write("File size: " + extractor.GetSize(i) + "<br>");
            }

            Response.End();

            extractor.Dispose();
        }
        static void Main(string[] args)
        {
            // Create Bytescout.PDFExtractor.AttachmentExtractor instance
            AttachmentExtractor extractor = new AttachmentExtractor();

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

            // Load sample PDF document
            extractor.LoadDocumentFromFile("Beispielrechnung_ZUGFeRD_RC_COMFORT_neu.pdf");

            // extracting XML invoice which is stored as an attachment
            for (int i = 0; i < extractor.Count; i++)
            {
                Console.WriteLine("Saving XML invoice attachment:\t" + extractor.GetFileName(i));

                // save file into the current folder
                extractor.Save(i, extractor.GetFileName(i));

                Console.WriteLine("Done.");
            }


            Console.WriteLine();
            Console.WriteLine("Press any key to open the XML invoice extracted...");
            Console.ReadLine();


            // Open the invoice in default XML viewer
            System.Diagnostics.Process.Start("ZUGFeRD-invoice.xml");
        }
Exemple #5
0
        //Invoked by "BatchExtract".
        public void BatchExtract(string indexString, string folderPath, NamingInfo namingInfo)
        {
            progressBar.Visibility = Visibility.Visible;
            progressBar.Value      = 0;
            PBSetValue(5);

            XmlDocument smryXml     = GetRightSummaryXml();
            XmlNodeList summaryList = smryXml.GetElementsByTagName("Summary");

            PBSetValue(20);

            //Create file name ArrayList by users selected naming method.
            ArrayList fileNames = new ArrayList();

            switch (namingInfo.namingMethod)
            {
            case NamingMethod.Enumerate:
                for (int i = 1; i <= summaryList.Count; i++)
                {
                    fileNames.Add(i.ToString());
                }
                break;

            case NamingMethod.Origin:
                for (int i = 0; i < summaryList.Count; i++)
                {
                    fileNames.Add(System.IO.Path.GetFileNameWithoutExtension(((XmlElement)summaryList[i]).GetAttribute("path")));
                }
                break;

            case NamingMethod.Att:
                foreach (WrapPanel tempWrap in listBox.Items)
                {
                    string contentString = (tempWrap.Children[1] as TextBlock).Text;

                    fileNames.Add(System.IO.Path.GetFileNameWithoutExtension(contentString.Substring("Content= \"".Count(), contentString.Count() - "Content= \"".Count()).TrimEnd('\"')));
                }
                break;

            case NamingMethod.Index:
                fileNames.Add(new string[1] {
                    namingInfo.indexString
                });
                break;
            }
            PBSetValue(40);

            extractInfo eInfo = new extractInfo(ref smryXml, indexString, fileNames, folderPath);

            AttachmentExtractor.Extract(eInfo);

            PBSetValue(100);

            progressBar.Visibility = Visibility.Hidden;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // This test file will be copied to the project directory on the pre-build event (see the project properties).
            String inputFile = Server.MapPath("Beispielrechnung_ZUGFeRD_RC_COMFORT_neu.pdf");

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

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

            // Load sample PDF document
            extractor.LoadDocumentFromFile(inputFile);

            Response.Clear();
            Response.ContentType = "text/html";

            Response.Write("<html><body>\r\n");

            // output the attached XML file
            for (int i = 0; i < extractor.Count; i++)
            {
                Response.Write("Saving XML invoice attachment:       " + extractor.GetFileName(i) + "<br>");
                MemoryStream mem = new MemoryStream();
                Response.Write("File size: " + extractor.GetSize(i).ToString() + "<br>");

                // optionally save XML invoice to a file
                // extractor.Save (i, extractor.GetFileName(i)); // you can save into temp folder or save to Stream object to avoid temp files

                extractor.SaveToStream(i, mem);
                mem.Position = 0;                              // reset the stream position
                StreamReader sreader    = new StreamReader(mem);
                string       XMLInvoice = sreader.ReadToEnd(); // xml invoice content

                Response.Write("<textarea rows='20' cols='80'><pre>" + HttpUtility.HtmlEncode(XMLInvoice) + "</pre></textarea>");
            }

            Response.Write("\r\n</body></html>");

            Response.End();
        }
Exemple #7
0
        static void Main()
        {
            // Create Bytescout.PDFExtractor.AttachmentExtractor instance
            AttachmentExtractor extractor = new AttachmentExtractor();

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

            // Load sample PDF document
            extractor.LoadDocumentFromFile("attachments.pdf");

            for (int i = 0; i < extractor.Count; i++)
            {
                Console.WriteLine("Saving attachment: " + extractor.GetFileName(i));
                // Save attachment to file
                extractor.Save(i, extractor.GetFileName(i));
                Console.WriteLine("File size: " + extractor.GetSize(i));
            }

            extractor.Dispose();
        }
Exemple #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String inputFile = Server.MapPath(@".\bin\ZUGFeRD-invoice.pdf");

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

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

            // Load sample PDF document
            extractor.LoadDocumentFromFile(inputFile);

            Response.Clear();
            Response.ContentType = "text/html";

            Response.Write("<html><body>\r\n");

            // Display attached ZUGFeRD XML data
            for (int i = 0; i < extractor.Count; i++)
            {
                Response.Write("ZUGFeRD XML invoice attachment: " + extractor.GetFileName(i) + "<br/>");
                MemoryStream mem = new MemoryStream();
                Response.Write("File size: " + extractor.GetSize(i) + "<br/>");

                // You can save the file into temp folder or save to stream to avoid temp files
                //extractor.Save(i, extractor.GetFileName(i));

                extractor.SaveToStream(i, mem);
                mem.Position = 0;                                  // reset the stream position
                StreamReader sreader        = new StreamReader(mem);
                string       zugferdXmlData = sreader.ReadToEnd(); // XML content

                Response.Write("<textarea rows='20' cols='80'>" + HttpUtility.HtmlEncode(zugferdXmlData) + "</textarea>");
            }

            Response.Write("\r\n</body></html>");

            Response.End();
        }
Exemple #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            String inputFile = Server.MapPath(@".\bin\attachments.pdf");

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

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

            // Load sample PDF document
            extractor.LoadDocumentFromFile(inputFile);

            Response.Clear();
            Response.ContentType = "text/html";

            for (int i = 0; i < extractor.Count; i++)
            {
                string attachmentFileName = extractor.GetFileName(i);
                int    attachmentFileSize = extractor.GetSize(i);

                Response.Write("Found attachment: " + attachmentFileName + "<br/>");

                // You can save the attachment to a file
                //extractor.Save(i, attachmentFileName);

                // ... or write to output stream
                //extractor.Save(i, Response.OutputStream);

                Response.Write("- file size: " + attachmentFileSize + "<br/><br/>");
            }

            Response.End();

            extractor.Dispose();
        }