private static void AddCustomCost(PdfPTable table, SimpleInvoiceDetails simpleInvoiceDetails, double subTotal)
        {
            table.AddCell(ElementFactory.CreateCell(simpleInvoiceDetails.Quantity.ToString(CultureInfo.InvariantCulture)));

            table.AddCell(ElementFactory.CreateCell(simpleInvoiceDetails.Description, Element.ALIGN_LEFT, 200));

            table.AddCell(ElementFactory.CreateCell(string.Format("{0}", simpleInvoiceDetails.UnitPrice)));

            table.AddCell(ElementFactory.CreateCell(subTotal.ToString(CurrencyString), Element.ALIGN_RIGHT));
        }
        public static void CreateCustom(Document document, SimpleInvoiceDetails simpleInvoiceDetails, InvoiceEntity invoiceEntity)
        {
            var table = new PdfPTable(4) { WidthPercentage = 100 };
            var colWidthPercentages = new[] { 1f, 3f, 1f, 1f };
            table.SetWidths(colWidthPercentages);

            var subTotal = simpleInvoiceDetails.Quantity * simpleInvoiceDetails.UnitPrice;

            AddHeader(table);
            AddCustomCost(table, simpleInvoiceDetails, subTotal);
            AddSummary(table, subTotal, subTotal * 0.2);

            document.Add(table);
        }
예제 #3
0
        public string CreateCustomInvoice(InvoiceEntity invoiceEntity, SimpleInvoiceDetails simpleInvoiceDetails, CompanyInformationEntity companyInformationEntity, DateTime now, string invoiceFolder)
        {
            DirectoryCreator.EnsureExistance(invoiceFolder);

            var pdfFileName = FileNameProvider.GetAvailableFileName(invoiceFolder + "\\Invoice-", InvoiceNameGenerator.GetName(simpleInvoiceDetails.Number, now), ".pdf");

            var pdfDoc = new Document(PageSize.A4, 50, 50, 25, 25);
            var output = new FileStream(pdfFileName, FileMode.OpenOrCreate);
            PdfWriter.GetInstance(pdfDoc, output);

            pdfDoc.Open();

            HeaderFactory.Create(pdfDoc, simpleInvoiceDetails.Number, invoiceEntity, companyInformationEntity,now);

            ClientInfoFactory.Create(pdfDoc, CompositeAddressCreator.CreateAddress(simpleInvoiceDetails.Client.CompanyInformationEntity), simpleInvoiceDetails.CommentsOrSpecialInstructions);

            CostSummaryFactory.CreateCustom(pdfDoc, simpleInvoiceDetails, invoiceEntity);
            FooterFactory.Create(pdfDoc, invoiceEntity);

            pdfDoc.Close();

            return pdfFileName;
        }