Ejemplo n.º 1
0
        public string Generate(Trade trade)
        {
            var document = new PdfDocument();
            var page = document.AddPage();
            page.Size = PageSize;
            var gfx = XGraphics.FromPdfPage(page);

            GenerateHeader(gfx);
            GenerateBody(gfx, trade);
            GenerateConditions(gfx);
            GenerateSignatureFields(gfx, trade);
            GenerateReferenceId(gfx, trade);

            var filename = @"test_" + trade.CreatedAt.ToString(DateFormat) + ".pdf";
            document.Save(filename);
            return filename;
        }
Ejemplo n.º 2
0
        private static void GenerateBody(XGraphics gfx, Trade trade)
        {
            var tf = CreateTextFormatter(gfx);
            tf.DrawString(@"Contract ID:
            Date:

            Buyer:
            Seller:

            Price:
            Notes:", Font, TextBrush, BodyRectLeft, XStringFormats.TopLeft);

            var font = Font;
            var rect = BodyRectRight;
            CheckWidth(gfx, font, rect, trade.Buyer.CompanyName + "/" + trade.Buyer.FullName);
            CheckWidth(gfx, font, rect, trade.Seller.CompanyName + "/" + trade.Seller.FullName);

            tf.DrawString(string.Format("{0}\n{1}\n\n{2}\n{3}\n\n{4}\n{5}",
                trade.TradeIdDisplay,
                trade.CreatedAt.ToString(DateFormat),
                trade.Buyer.CompanyName + "/" + trade.Buyer.FullName,
                trade.Seller.CompanyName + "/" + trade.Seller.FullName,
                "$150",
                "Candy tastes good."), font, TextBrush, rect, XStringFormats.TopLeft);
        }
Ejemplo n.º 3
0
        private static void GenerateSignatureFields(XGraphics gfx, Trade trade)
        {
            var color = XPens.Black;
            const int x1 = Margin;
            var x2 = x1 + Width;
            var tf = CreateTextFormatter(gfx);

            AddSignatureField(gfx, tf, color, trade.Buyer.CompanyName, x1, x2, SignatureY[Signee.Buyer]);
            AddSignatureField(gfx, tf, color, trade.Seller.CompanyName, x1, x2, SignatureY[Signee.Seller]);
            AddSignatureField(gfx, tf, color, "Acme, LLC", x1, x2, SignatureY[Signee.Admin]);
        }
Ejemplo n.º 4
0
 private static void GenerateReferenceId(XGraphics gfx, Trade trade)
 {
     var text = "Reference ID: " + trade.TradeId.ToString().ToUpper();
     var tf = CreateTextFormatter(gfx);
     tf.DrawString(
         text,
         ConditionsFont,
         TextBrush,
         new XRect(PageWidth - Margin - gfx.MeasureString(text, ConditionsFont).Width, PageSizeConverter.ToSize(PageSize).Height - Margin - ConditionsFont.GetHeight(), Width, ConditionsFont.GetHeight()),
         XStringFormats.TopLeft);
 }