Exemple #1
0
        public Bill(String path, String lang)
        {
            CultureInfo ci = new CultureInfo(lang);

            String input = PDFUtil.ReadPdf(path);

            /*
             * Fecha de Expedición:
             * Fecha de Orden de Compra:
             * 2019-08-05T16:02:48-05:00 8/5/2019
             */

            this.code  = Utils.GetText(input, "Factura Folio Interno: ", "\n");
            this.date  = Utils.ToDate(Utils.GetText(input, "Fecha de Orden de Compra:\n", "T"), "yyyy-MM-dd"); // 2019-01-24
            this.total = Utils.ToDouble(Utils.GetText(input, "\nTotal\n", "\n"), ci);
            String codes = Utils.GetText(input, code + "\n", "\n");

            String intemsZone = Utils.GetText(input, "Total\n", "\nAVISO:\n");

            String[] pages     = Utils.SplitText(intemsZone, "\nEste documento es una representación impresa de un CFDI");
            String   itemsText = pages[0];

            for (int i = 1; i < pages.Length - 1; i++)
            {
                itemsText += Utils.GetText(pages[i], codes);
            }
            String[] lines = Utils.Split(itemsText, "\n");
            foreach (String line in lines)
            {
                if (Utils.Split(line, " ").Length > 8)
                {
                    this.items.Add(new BillItem(line, ci));
                }
            }
        }
        public OrderList(String path)
        {
            String input = PDFUtil.ReadPdf(path);

            this.id        = Utils.GetText(input, "Entrega No.: ", "\n");
            this.date      = Utils.ToDate(Utils.GetText(input, "Fecha: ", "\n"), "dd.MM.yyyy");
            this.order     = Utils.GetText(input, "Pedido No.: ", "\n");
            this.code      = Utils.GetText(input, "Su no. de pedido: ", "\n");
            this.condition = Utils.GetText(input, "Condición de despacho: ", "\n");
            this.incoterm  = Utils.GetText(input, "Incoterm: ", "\n");

            String packsText = Utils.GetText(input, "\nempaque\n", "\nSuma de peso");

            String[] lines = Utils.Split(packsText, "\n");
            for (int i = 0; i < lines.Length; i++)
            {
                if (Utils.Split(lines[i], " ").Length > 5)
                {
                    String packedCode = Utils.Split(lines[i], " ")[1];
                    if (packedCode.EndsWith("*"))
                    {
                        packedCode = Utils.Split(lines[++i], " ")[0];
                    }
                    String itemsText = Utils.GetText(input, "\nHu-Nr.: " + packedCode);
                    itemsText = Utils.SplitText(itemsText, "\nHu-Nr.: ")[0];
                    String   zoneItems  = "";
                    String[] zonesItems = Utils.Split(itemsText, "UKZ\n");
                    for (int j = 1; j < zonesItems.Length; j++)
                    {
                        zoneItems += Utils.Split(zonesItems[j], "\nPágina\n")[0];
                        int le = zoneItems.LastIndexOf('\n');
                        zoneItems = zoneItems.Substring(0, le + 1);
                    }

                    String[] itemsLines = Utils.Split(zoneItems, "\n");
                    foreach (String itemLine in itemsLines)
                    {
                        String[] dataLine = Utils.Split(itemLine, " ");
                        if (dataLine.Length > 5 && Utils.IsInteger(dataLine[0]))
                        {
                            this.items.Add(new OrderListItem(packedCode, itemLine));
                        }
                    }
                }
            }
        }