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();
        }
        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();
        }
예제 #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();
        }
예제 #4
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();
        }
예제 #5
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();
        }