Ejemplo n.º 1
0
        private void MakePdfDocumentForEnvelopes(PdfDocument pdfDoc, Dictionary <int, EnvelopeAddress> envelopes)
        {
            EnvelopeFormat format = new EnvelopeFormat();
            XFont          xfont  = GetEnvelopesXFont();

            foreach (var envelope in envelopes.Values)
            {
                PdfPage pdfPage = CreateNewPage(pdfDoc, false);
                SetPageSize(pdfPage, format.Width, format.Height);
                FillPdfPageWithEnvelope(pdfPage, envelope.SenderText, envelope.RecipientText, format, xfont);
            }
        }
Ejemplo n.º 2
0
        private static void FillPdfPageWithEnvelope(PdfPage pdfPage, string senderAddress, string recipientAddress, EnvelopeFormat format, XFont xfont)
        {
            using (XGraphics graphicsDc = XGraphics.FromPdfPage(pdfPage, XGraphicsUnit.Inch))
            {
                //sender Address Area
                float   left       = format.SenderCell.Left;
                float   top        = format.SenderCell.Top;
                float   bottom     = top + format.SenderCell.Height;
                float   right      = left + format.SenderCell.Width;
                PdfCell returnCell = new PdfCell()
                {
                    Left       = left,
                    Top        = top,
                    Width      = right - left,
                    Height     = bottom - top,
                    TopMargin  = format.SenderCell.TopMargin,
                    LeftMargin = format.SenderCell.LeftMargin
                };
                returnCell.XFont = xfont;

                if (returnCell.ShowMarkupLines)
                {
                    PaintPdfCellLines(graphicsDc, left, right, top, bottom);
                }
                PaintPdfCellText(graphicsDc, senderAddress, returnCell);

                //Recipient Address Area
                left = format.RecipientCell.Left;
                //top = format.RecipientCell.Top;
                top    = 2;
                bottom = top + format.RecipientCell.Height;
                right  = left + format.RecipientCell.Width;
                PdfCell recipientCell = new PdfCell()
                {
                    //Left = left,
                    Left      = 0,
                    Top       = top,
                    Width     = right - left,
                    Height    = bottom - top,
                    TopMargin = format.RecipientCell.TopMargin,
                    //LeftMargin = format.RecipientCell.LeftMargin
                    LeftMargin = 4
                };
                recipientCell.XFont = xfont;
                if (recipientCell.ShowMarkupLines)
                {
                    PaintPdfCellLines(graphicsDc, left, right, top, bottom);
                }
                PaintPdfCellText(graphicsDc, recipientAddress, recipientCell);
            }
        }