Inheritance: Barcode
Example #1
63
// ===========================================================================
    public void Write(Stream stream) {
      // step 1
      using (Document document = new Document(new Rectangle(340, 842))) {
        // step 2
        PdfWriter writer = PdfWriter.GetInstance(document, stream);
        // step 3
        document.Open();
        // step 4
        PdfContentByte cb = writer.DirectContent;

        // EAN 13
        document.Add(new Paragraph("Barcode EAN.UCC-13"));
        BarcodeEAN codeEAN = new BarcodeEAN();
        codeEAN.Code = "4512345678906";
        document.Add(new Paragraph("default:"));
        document.Add(codeEAN.CreateImageWithBarcode(cb, null, null));
        codeEAN.GuardBars = false;
        document.Add(new Paragraph("without guard bars:"));
        document.Add(codeEAN.CreateImageWithBarcode(cb, null, null));
        codeEAN.Baseline = -1f;
        codeEAN.GuardBars = true;
        document.Add(new Paragraph("text above:"));
        document.Add(codeEAN.CreateImageWithBarcode(cb, null, null));
        codeEAN.Baseline = codeEAN.Size;

        // UPC A
        document.Add(new Paragraph("Barcode UCC-12 (UPC-A)"));
        codeEAN.CodeType = Barcode.UPCA;
        codeEAN.Code = "785342304749";
        document.Add(codeEAN.CreateImageWithBarcode(cb, null, null));

        // EAN 8
        document.Add(new Paragraph("Barcode EAN.UCC-8"));
        codeEAN.CodeType = Barcode.EAN8;
        codeEAN.BarHeight = codeEAN.Size * 1.5f;
        codeEAN.Code = "34569870";
        document.Add(codeEAN.CreateImageWithBarcode(cb, null, null));

        // UPC E
        document.Add(new Paragraph("Barcode UPC-E"));
        codeEAN.CodeType = Barcode.UPCE;
        codeEAN.Code = "03456781";
        document.Add(codeEAN.CreateImageWithBarcode(cb, null, null));
        codeEAN.BarHeight = codeEAN.Size * 3f;

        // EANSUPP
        document.Add(new Paragraph("Bookland"));
        document.Add(new Paragraph("ISBN 0-321-30474-8"));
        codeEAN.CodeType = Barcode.EAN13;
        codeEAN.Code = "9781935182610";
        BarcodeEAN codeSUPP = new BarcodeEAN();
        codeSUPP.CodeType = Barcode.SUPP5;
        codeSUPP.Code = "55999";
        codeSUPP.Baseline = -2;
        BarcodeEANSUPP eanSupp = new BarcodeEANSUPP(codeEAN, codeSUPP);
        document.Add(eanSupp.CreateImageWithBarcode(cb, null, BaseColor.BLUE));

        // CODE 128
        document.Add(new Paragraph("Barcode 128"));
        Barcode128 code128 = new Barcode128();
        code128.Code = "0123456789 hello";
        document.Add(code128.CreateImageWithBarcode(cb, null, null));
        code128.Code = "0123456789\uffffMy Raw Barcode (0 - 9)";
        code128.CodeType = Barcode.CODE128_RAW;
        document.Add(code128.CreateImageWithBarcode(cb, null, null));

        // Data for the barcode :
        String code402 = "24132399420058289";
        String code90 = "3700000050";
        String code421 = "422356";
        StringBuilder data = new StringBuilder(code402);
        data.Append(Barcode128.FNC1);
        data.Append(code90);
        data.Append(Barcode128.FNC1);
        data.Append(code421);
        Barcode128 shipBarCode = new Barcode128();
        shipBarCode.X = 0.75f;
        shipBarCode.N = 1.5f;
        shipBarCode.Size = 10f;
        shipBarCode.TextAlignment = Element.ALIGN_CENTER;
        shipBarCode.Baseline = 10f;
        shipBarCode.BarHeight = 50f;
        shipBarCode.Code = data.ToString();
        document.Add(shipBarCode.CreateImageWithBarcode(
          cb, BaseColor.BLACK, BaseColor.BLUE
        ));

        // it is composed of 3 blocks whith AI 01, 3101 and 10
        Barcode128 uccEan128 = new Barcode128();
        uccEan128.CodeType = Barcode.CODE128_UCC;
        uccEan128.Code = "(01)00000090311314(10)ABC123(15)060916";
        document.Add(uccEan128.CreateImageWithBarcode(
          cb, BaseColor.BLUE, BaseColor.BLACK
        ));
        uccEan128.Code = "0191234567890121310100035510ABC123";
        document.Add(uccEan128.CreateImageWithBarcode(
          cb, BaseColor.BLUE, BaseColor.RED
        ));
        uccEan128.Code = "(01)28880123456788";
        document.Add(uccEan128.CreateImageWithBarcode(
          cb, BaseColor.BLUE, BaseColor.BLACK
        ));

        // INTER25
        document.Add(new Paragraph("Barcode Interleaved 2 of 5"));
        BarcodeInter25 code25 = new BarcodeInter25();
        code25.GenerateChecksum = true;
        code25.Code = "41-1200076041-001";
        document.Add(code25.CreateImageWithBarcode(cb, null, null));
        code25.Code = "411200076041001";
        document.Add(code25.CreateImageWithBarcode(cb, null, null));
        code25.Code = "0611012345678";
        code25.ChecksumText = true;
        document.Add(code25.CreateImageWithBarcode(cb, null, null));

        // POSTNET
        document.Add(new Paragraph("Barcode Postnet"));
        BarcodePostnet codePost = new BarcodePostnet();
        document.Add(new Paragraph("ZIP"));
        codePost.Code = "01234";
        document.Add(codePost.CreateImageWithBarcode(cb, null, null));
        document.Add(new Paragraph("ZIP+4"));
        codePost.Code = "012345678";
        document.Add(codePost.CreateImageWithBarcode(cb, null, null));
        document.Add(new Paragraph("ZIP+4 and dp"));
        codePost.Code = "01234567890";
        document.Add(codePost.CreateImageWithBarcode(cb, null, null));

        document.Add(new Paragraph("Barcode Planet"));
        BarcodePostnet codePlanet = new BarcodePostnet();
        codePlanet.Code = "01234567890";
        codePlanet.CodeType = Barcode.PLANET;
        document.Add(codePlanet.CreateImageWithBarcode(cb, null, null));

        // CODE 39
        document.Add(new Paragraph("Barcode 3 of 9"));
        Barcode39 code39 = new Barcode39();
        code39.Code = "ITEXT IN ACTION";
        document.Add(code39.CreateImageWithBarcode(cb, null, null));

        document.Add(new Paragraph("Barcode 3 of 9 extended"));
        Barcode39 code39ext = new Barcode39();
        code39ext.Code = "iText in Action";
        code39ext.StartStopText = false;
        code39ext.Extended = true;
        document.Add(code39ext.CreateImageWithBarcode(cb, null, null));

        // CODABAR
        document.Add(new Paragraph("Codabar"));
        BarcodeCodabar codabar = new BarcodeCodabar();
        codabar.Code = "A123A";
        codabar.StartStopText = true;
        document.Add(codabar.CreateImageWithBarcode(cb, null, null));

        // PDF417
        document.Add(new Paragraph("Barcode PDF417"));
        BarcodePDF417 pdf417 = new BarcodePDF417();
        String text = "Call me Ishmael. Some years ago--never mind how long "
        + "precisely --having little or no money in my purse, and nothing "
              + "particular to interest me on shore, I thought I would sail about "
              + "a little and see the watery part of the world."
            ;
        pdf417.SetText(text);
        Image img = pdf417.GetImage();
        img.ScalePercent(50, 50 * pdf417.YHeight);
        document.Add(img);

        document.Add(new Paragraph("Barcode Datamatrix"));
        BarcodeDatamatrix datamatrix = new BarcodeDatamatrix();
        datamatrix.Generate(text);
        img = datamatrix.CreateImage();
        document.Add(img);

        document.Add(new Paragraph("Barcode QRCode"));
        BarcodeQRCode qrcode = new BarcodeQRCode(
          "Moby Dick by Herman Melville", 1, 1, null
        );
        img = qrcode.GetImage();
        document.Add(img);        
      }
    }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ISeguranca iseguranca = Factory.GetInstance<ISeguranca>();
                if (!iseguranca.VerificarPermissao(((ViverMais.Model.Usuario)Session["Usuario"]).Codigo, "ALTERAR_CARTAO_SUS",Modulo.CARTAO_SUS))
                {
                    ClientScript.RegisterClientScriptBlock(typeof(String), "ok", "<script>alert('Você não tem permissão para acessar essa página. Em caso de dúViverMais, entre em contato.');window.location='../Home.aspx';</script>");
                }
            }

            if (Request.QueryString["codigo"] != null)
            {
                IPaciente ipaciente = Factory.GetInstance<IPaciente>();
                ViverMais.Model.Paciente paciente = ipaciente.BuscarPorCodigo<ViverMais.Model.Paciente>(Request.QueryString["codigo"]);
                IList<CartaoSUS> cartoes = ipaciente.ListarCartoesSUS<ViverMais.Model.CartaoSUS>(paciente.Codigo);
                long result = (from c in cartoes select long.Parse(c.Numero)).Min();
                Barcode39 code39 = new Barcode39();
                code39.Code = result.ToString();
                code39.StartStopText = true;
                code39.GenerateChecksum = false;
                code39.Extended = true;
                System.Drawing.Image img = code39.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White);
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                img.Save (ms, System.Drawing.Imaging.ImageFormat.Gif);
                Response.ClearContent();
                Response.ContentType = "image/Gif";
                Response.BinaryWrite(ms.ToArray());
            }
        }
        protected void GenerateBarcode(object sender, EventArgs e)
        {
            if (ddlDocType.SelectedIndex ==0 || tbpatientid.Text == "")
            {
                lblError.Text = "You must fill in all the required fields.";
                notificationerror.Attributes.CssStyle.Add(HtmlTextWriterStyle.Display, "block");
                return;
            }

            var bc39 = new Barcode39();
            var visitId = ddlVisitDate.SelectedItem.Value;
            var type = ddlDocType.SelectedItem.Value;
            var chartId = ddlChartId.SelectedItem.Text;

            bc39.Code = visitId + "-" + type + "-" + chartId;
            var bc = BarcodeLib.Barcode.DoEncode(BarcodeLib.TYPE.CODE39, bc39.Code, true, Color.Black, Color.White, 200, 50);

            using (var ms = new MemoryStream())
            {
                bc.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
                ms.WriteTo(Response.OutputStream);
            }
            var fileName = "Temp_" + DateTime.Now.Ticks;
            var bcDirectory = Server.MapPath("~/barcode/Temp/" + fileName + ".gif");
            bc.Save(bcDirectory, System.Drawing.Imaging.ImageFormat.Gif);

            Response.Redirect("showBarcode.aspx?file=" + fileName);
        }
Example #4
0
        public void ProcessRequest(HttpContext context)
        {
            // iTextSharp.text.pdf.BarcodeQRCode qrcode = new BarcodeQRCode("just testing  the barcode", 50, 50, null);
            //iTextSharp.text.Image img = qrcode.GetImage();

            try
            {
                Barcode39 bc39 = new Barcode39();

                bc39.Code = "1234";
                System.Drawing.Image bc = bc39.CreateDrawingImage(System.Drawing.Color.Black,System.Drawing.Color.White);

                context.Response.ContentType = "image/gif";
                bc.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);

                //MemoryStream ms = new MemoryStream(img.RawData);
                //System.Drawing.Image returnImage = System.Drawing.Image.FromStream(ms);
                //returnImage.Save("img.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                //context.Response.ContentType = "image/jpeg";
                //context.Response.BinaryWrite(ms.ToArray());

            }
            catch (Exception ex)
            {
            }
        }
Example #5
0
        public void AddRow(PdfPTable t, string fname, string lname, string phone, int pid)
        {
            var bc = new Barcode39();
            bc.X = 1.2f;
            bc.Font = null;
            bc.Code = pid.ToString();
            var img = bc.CreateImageWithBarcode(dc, null, null);
            var p1 = new Phrase();
            p1.Add(new Chunk(img, 0, 0));
            p1.Add(new Phrase("\n\n" + fname + " " + lname + " (" + pid + ")", smallfont));
            var c = new PdfPCell(p1);
            c.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            c.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            c.Border = PdfPCell.NO_BORDER;
            c.FixedHeight = H * 72f;

            var t2 = new PdfPTable(2);
            t2.WidthPercentage = 100f;
            t2.DefaultCell.Border = PdfPCell.NO_BORDER;

            var cc = new PdfPCell(new Phrase(fname, font));
            cc.Border = PdfPCell.NO_BORDER;
            cc.Colspan = 2;
            t2.AddCell(cc);

            cc = new PdfPCell(new Phrase(lname, font));
            cc.Border = PdfPCell.NO_BORDER;
            cc.Colspan = 2;
            t2.AddCell(cc);

            var pcell = new PdfPCell(new Phrase(pid.ToString(), smallfont));
            pcell.Border = PdfPCell.NO_BORDER;
            pcell.HorizontalAlignment = Element.ALIGN_LEFT;
            t2.AddCell(pcell);

            pcell = new PdfPCell(new Phrase(phone.FmtFone(), smallfont));
            pcell.Border = PdfPCell.NO_BORDER;
            pcell.HorizontalAlignment = Element.ALIGN_RIGHT;
            t2.AddCell(pcell);

            var cell = new PdfPCell(t2);
            cell.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            cell.PaddingLeft = 8f;
            cell.PaddingRight = 8f;
            cell.Border = PdfPCell.NO_BORDER;
            cell.FixedHeight = H * 72f;

            t.AddCell(c);
            t.AddCell("");
            t.AddCell(cell);
            t.AddCell("");
            t.AddCell(cell);
        }
Example #6
0
        public bool AddCell(PdfPTable t, string desc, int code)
        {
            var bc = new Barcode39();
            bc.X = 1.2f;
            bc.Font = null;
            bc.Code = code.ToString();
            var img = bc.CreateImageWithBarcode(dc, null, null);
            var p = new Phrase();
            p.Add(new Chunk(img, 0, 0));
            p.Add(new Phrase("\n" + code.ToString().Insert(3," "), font));
            p.Add(new Phrase("\n" + desc, smallfont));
            var c = new PdfPCell(p);
            c.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            c.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
            c.Border = PdfPCell.NO_BORDER;
            c.FixedHeight = H * 72f;

            t.AddCell(c);
            n++;
            if (n % 3 > 0)
                t.AddCell("");
            return n % 3 == 0;
        }
Example #7
0
            public override void OnEndPage(PdfWriter writer, Document document)
            {
                base.OnEndPage(writer, document);
                if (npages.juststartednewset)
                    EndPageSet();

                string text;
                float len;

                //---Header left
                text = HeadText;
                const float HeadFontSize = 11f;
                len = font.GetWidthPoint(text, HeadFontSize);
                dc.BeginText();
                dc.SetFontAndSize(font, HeadFontSize);
                dc.SetTextMatrix(30, document.PageSize.Height - 30);
                dc.ShowText(text);
                dc.EndText();
                dc.BeginText();
                dc.SetFontAndSize(font, HeadFontSize);
                dc.SetTextMatrix(30, document.PageSize.Height - 30 - (HeadFontSize * 1.5f));
                dc.ShowText(HeadText2);
                dc.EndText();

                //---Barcode right
                var bc = new Barcode39();
                bc.Font = null;
                bc.Code = Barcode;
                bc.X = 1.2f;
                var img = bc.CreateImageWithBarcode(dc, null, null);
                var h = font.GetAscentPoint(text, HeadFontSize);
                img.SetAbsolutePosition(document.PageSize.Width - img.Width - 30, document.PageSize.Height - 30 - img.Height + h);
                dc.AddImage(img);

                //---Column 1
                text = "Page " + (pg) + " of ";
                len = font.GetWidthPoint(text, 8);
                dc.BeginText();
                dc.SetFontAndSize(font, 8);
                dc.SetTextMatrix(30, 30);
                dc.ShowText(text);
                dc.EndText();
                dc.AddTemplate(npages.template, 30 + len, 30);
                npages.n = pg++;

                //---Column 2
                text = "Attendance Rollsheet";
                len = font.GetWidthPoint(text, 8);
                dc.BeginText();
                dc.SetFontAndSize(font, 8);
                dc.SetTextMatrix(document.PageSize.Width / 2 - len / 2, 30);
                dc.ShowText(text);
                dc.EndText();

                //---Column 3
                text = Util.Now.ToShortDateString();
                len = font.GetWidthPoint(text, 8);
                dc.BeginText();
                dc.SetFontAndSize(font, 8);
                dc.SetTextMatrix(document.PageSize.Width - 30 - len, 30);
                dc.ShowText(text);
                dc.EndText();
            }
Example #8
0
        private PdfPTable AddRow(string Code, string name, int pid, string dob, string highlight, Font font)
        {
            var t = new PdfPTable(4);
            //t.SplitRows = false;
            t.WidthPercentage = 100;
            t.SetWidths(new int[] { 30, 4, 6, 30 });
            t.DefaultCell.Border = PdfPCell.NO_BORDER;

            var bc = new Barcode39();
            bc.X = 1.2f;
            bc.Font = null;
            bc.Code = pid.ToString();
            var img = bc.CreateImageWithBarcode(dc, null, null);
            var c = new PdfPCell(img, false);
            c.PaddingTop = 3f;
            c.Border = PdfPCell.NO_BORDER;
            c.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            t.AddCell(c);

            t.AddCell("");
            t.AddCell(box);

            DateTime bd;
            DateTime.TryParse(dob, out bd);

            var p = new Phrase(name, font);
            p.Add("\n");
            p.Add(new Chunk(" ", medfont));
            p.Add(new Chunk("({0}) {1:MMM d}".Fmt(Code, bd), smallfont));
            if (highlight.HasValue())
                p.Add("\n" + highlight);
            t.AddCell(p);
            hasRows = true;
            return t;
        }
Example #9
0
        private void AddRow(string name, int pid, int? oid, Font font)
        {
            var bco = new Barcode39();
            bco.X = 1.2f;
            bco.Font = null;
            bco.Code = "M.{0}.{1}".Fmt(oid,pid);
            var img = bco.CreateImageWithBarcode(dc, null, null);
            var c = new PdfPCell(img, false);
            c.PaddingTop = 3f;
            c.Border = PdfPCell.NO_BORDER;
            c.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            t.AddCell(c);

            t.AddCell("");
            t.AddCell(box);

            t.AddCell(name);
            t.AddCell("({0}, {1})".Fmt(
                oid.HasValue ? oid.ToString() : " N/A ", pid));
        }
Example #10
0
        public void BarcodesTest1() {
            Document document = new Document();
            PdfAWriter writer = PdfAWriter.GetInstance(document, new
                FileStream(OUT + "barcodesTest1.pdf", FileMode.Create), PdfAConformanceLevel.PDF_A_3A);

            writer.SetTagged();
            document.Open();
            writer.ViewerPreferences = PdfWriter.DisplayDocTitle;
            document.AddTitle("Some title");
            document.AddLanguage("en-us");
            writer.CreateXmpMetadata();

            document.NewPage();

            // Set output intent. PDF/A requirement.
            FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open,
                FileAccess.Read, FileShare.Read);
            ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);
            iccProfileFileStream.Close();
            writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);

            // All fonts shall be embedded. PDF/A requirement.
            Font normal9 = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 9);
            Font normal8 = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 8);

            BaseColor color = new BaseColor(111, 211, 11);
            normal8.Color = color;

            PdfContentByte cb = writer.DirectContent;

            String code = "119716-500023718";
            Barcode barcode = new Barcode39();
            barcode.Code = code;
            barcode.StartStopText = false;
            barcode.Font = normal9.BaseFont;
            barcode.Extended = true;

            Image image = barcode.CreateImageWithBarcode(cb, color, color);
            image.Alt = "Bla Bla";
            document.Add(image);

            document.Close();
        }
Example #11
0
 public Image GetBarcode39(PdfContentByte pdfContentByte, string code, bool extended)
 {
     Barcode39 barcode39 = new Barcode39 { Code = code, StartStopText = false, Extended = extended };
     return barcode39.CreateImageWithBarcode(pdfContentByte, null, null);
 }
Example #12
0
        private void AddRow(string name, int pid, int? oid, Font font)
        {
            var bco = new Barcode39();
            bco.X = 1.2f;
            bco.Font = null;
            bco.Code = $"M.{oid}.{pid}";
            var img = bco.CreateImageWithBarcode(dc, null, null);
            var c = new PdfPCell(img, false);
            c.PaddingTop = 3f;
            c.Border = PdfPCell.NO_BORDER;
            c.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            t.AddCell(c);

            t.AddCell("");
            t.AddCell(box);

            t.AddCell(name);
            t.AddCell($"({oid?.ToString() ?? " N/A "}, {pid})");
        }
Example #13
0
        private void AddCartaoSUSCompleto(long numeroCartaoSUS)
        {
            ISeguranca iseguranca = Factory.GetInstance<ISeguranca>();
            if (!iseguranca.VerificarPermissao(((ViverMais.Model.Usuario)Session["Usuario"]).Codigo, "ALTERAR_CARTAO_SUS", Modulo.CARTAO_SUS))
            {
                ClientScript.RegisterClientScriptBlock(typeof(String), "ok", "<script>alert('Você não tem permissão para acessar essa página. Em caso de dúViverMais, entre em contato.');window.location='../Home.aspx';</script>");
                return;
            }

            MemoryStream MStream = new MemoryStream();
            iTextSharp.text.Document doc = new iTextSharp.text.Document(new iTextSharp.text.Rectangle(295, 191));
            PdfWriter writer = PdfWriter.GetInstance(doc, MStream);

            //Monta o pdf
            doc.Open();
            iTextSharp.text.Paragraph p = new iTextSharp.text.Paragraph();
            p.IndentationLeft = -10;
            p.Font.Color = iTextSharp.text.Color.BLACK;
            iTextSharp.text.Phrase nome = new iTextSharp.text.Phrase(HiddenNomePaciente.Value + "\n");
            //paciente.Nome
            nome.Font.Size = 8;
            iTextSharp.text.Phrase nascimento = new iTextSharp.text.Phrase(HiddenDataNascimento.Value + "\t\t" + HiddenMunicipio.Value + "\n");
            nascimento.Font.Size = 8;
            iTextSharp.text.Phrase cartaosus = new iTextSharp.text.Phrase(numeroCartaoSUS + "\n");
            cartaosus.Font.Size = 12;
            PdfContentByte cb = writer.DirectContent;
            Barcode39 code39 = new Barcode39();
            code39.Code = numeroCartaoSUS.ToString();
            code39.StartStopText = true;
            code39.GenerateChecksum = false;
            code39.Extended = true;
            iTextSharp.text.Image imageEAN = code39.CreateImageWithBarcode(cb, null, null);

            iTextSharp.text.Image back = iTextSharp.text.Image.GetInstance(Server.MapPath("img/") + "back_card.JPG");
            back.SetAbsolutePosition(0, doc.PageSize.Height - back.Height);

            iTextSharp.text.Image front = iTextSharp.text.Image.GetInstance(Server.MapPath("img/") + "front_card.JPG");
            front.SetAbsolutePosition(0, doc.PageSize.Height - front.Height);

            iTextSharp.text.Phrase barcode = new iTextSharp.text.Phrase(new iTextSharp.text.Chunk(imageEAN, 36, -45));
            barcode.Font.Color = iTextSharp.text.Color.WHITE;

            p.SetLeading(1, 0.7f);
            p.Add(cartaosus);
            p.Add(nome);
            p.Add(nascimento);
            p.Add(barcode);
            doc.Add(p);

            doc.Add(back);
            doc.NewPage();
            doc.Add(front);

            doc.Close();
            //Fim monta pdf

            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.ClearHeaders();
            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=CartaoSUS.pdf");
            HttpContext.Current.Response.BinaryWrite(MStream.GetBuffer());
            HttpContext.Current.Response.End();
        }