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();
        }
        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();
        }
Exemple #3
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 #4
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();
        }