Beispiel #1
0
        public void Draw(MergerInvoiceData.Order data, Document document)
        {
            // Each Invoice should begin a new section
            document.Sections.Begin();

            // Adds the invoice if there is data
            if (data != null)
            {
                // Sets the Freight amount
                freight = (decimal)data.Freight;

                // Draws the invoice data, returns a page object if it is the last page
                int  i        = 0;
                Page lastPage = DrawInvoiceData(data, document, ref i);

                // Draws aditional pages if necessary
                while (lastPage == null)
                {
                    lastPage = DrawInvoiceData(data, document, ref i);
                }

                // Draws the totals to the bottom of the last page of the Invoice
                DrawTotals(data, document.Pages[document.Pages.Count - 1]);
            }
        }
Beispiel #2
0
        private void DrawTotals(MergerInvoiceData.Order data, Page page)
        {
            // Add totals to the bottom of the Invoice
            decimal grandTotal = subTotal + freight;

            page.Elements.Add(new Label(subTotal.ToString("#,##0.00"), 454, 668, 82, 12, Font.Helvetica, 12, TextAlign.Right));
            page.Elements.Add(new Label(freight.ToString("#,##0.00"), 454, 686, 82, 12, Font.Helvetica, 12, TextAlign.Right));
            page.Elements.Add(new Label(grandTotal.ToString("#,##0.00"), 454, 704, 82, 12, Font.Helvetica, 12, TextAlign.Right));
        }
Beispiel #3
0
 private void DrawInvoiceDetails(MergerInvoiceData.Order data, Page page)
 {
     // Adds Invoice details to the page
     page.Elements.Add(new Label(data.OrderID.ToString(), 437, 25, 100, 12, Font.Helvetica, 12));
     page.Elements.Add(new Label(((DateTime)data.OrderDate).ToString("d MMM yyyy"), 437, 39, 100, 12, Font.Helvetica, 12));
     page.Elements.Add(new Label(data.CustomerID.ToString(), 437, 53, 100, 12, Font.Helvetica, 12));
     if (!(data.ShippedDate == null))
     {
         page.Elements.Add(new Label(((DateTime)data.ShippedDate).ToString("d MMM yyyy"), 437, 67, 100, 12, Font.Helvetica, 12));
     }
     page.Elements.Add(new Label(data.ShipperName.ToString(), 437, 81, 100, 12, Font.Helvetica, 12));
     page.Elements.Add(new Interleaved25(data.OrderID.ToString(), 380, 4, 18, false));
     page.Elements.Add(new PageNumberingLabel("Page %%SP%% of %%ST%% ", 450, 253, 90, 20, Font.HelveticaBold, 12, TextAlign.Center));
 }
Beispiel #4
0
        private Page DrawInvoiceData(MergerInvoiceData.Order data, Document document, ref int start)
        {
            // Tracks if the invoice is finished
            bool invoiceFinished = true;

            // Tracks the y position on the page
            float yOffset = 288;

            // Create a page using "Invoice.pdf" as a template
            Page page = new ImportedPage(templatePath, 1);

            // Uncomment the line below to show a layout grid.
            //page.Elements.Add( new LayoutGrid() );

            // Add Details to the Invoice
            DrawInvoiceDetails(data, page);

            // Add bill to address
            page.Elements.Add(new TextArea(data.BillTo, 28, 139, 194, 70, Font.Helvetica, 12));

            // Add ship to address
            page.Elements.Add(new TextArea(data.ShipTo, 318, 139, 194, 70, Font.Helvetica, 12));

            // Add line items to the Invoice
            for (int i = start; i < data.OrderDetails.Count; i++)
            {
                DrawLineItem(data.OrderDetails[i], page, ref yOffset);
                // Break if at the bottom of the page
                if (yOffset >= 666)
                {
                    invoiceFinished = false;
                    start           = i + 1;
                    break;
                }
            }

            // Add the page to the document
            document.Pages.Add(page);

            // If Invoice is finished return the page else return null so another page will be added
            if (invoiceFinished)
            {
                return(page);
            }
            else
            {
                page.Elements.Add(new Label("Continued...", 454, 704, 82, 12, Font.Helvetica, 12, TextAlign.Right));
                return(null);
            }
        }