private static void addBarCodes(PdfStamper stamper, Tarima_almacen tarAlm1, Tarima_almacen tarAlm2, Tarima_almacen tarAlm3, Tarima_almacen tarAlm4) { PdfContentByte contentByte; try { contentByte = stamper.GetOverContent(1); int CTE_HEIGHT_CONST = 430; int CTE_X_POS_INI = 30; int CTE_Y_SPACE = -375; Image image = Image.GetInstance(BarCode.EncodeBytes(tarAlm1.Folio, false, 300, 50)); image.SetAbsolutePosition(CTE_X_POS_INI, CTE_HEIGHT_CONST);// set the position in the document where you want the watermark to appear (0,0 = bottom left corner of the page) //image.ScaleToFit(200, 25); contentByte.AddImage(image); //setAbsolutePosition 54 + 127 if (tarAlm2.Folio.Length > 0) { image = Image.GetInstance(BarCode.EncodeBytes(tarAlm2.Folio, false, 300, 50)); image.SetAbsolutePosition(CTE_X_POS_INI + 280, CTE_HEIGHT_CONST);// set the position in the document where you want the watermark to appear (0,0 = bottom left corner of the page) //image.ScaleToFit(200, 25); contentByte.AddImage(image); } if (tarAlm3.Folio.Length > 0) { image = Image.GetInstance(BarCode.EncodeBytes(tarAlm3.Folio, false, 300, 50)); image.SetAbsolutePosition(CTE_X_POS_INI, CTE_HEIGHT_CONST + CTE_Y_SPACE);// set the position in the document where you want the watermark to appear (0,0 = bottom left corner of the page) //image.ScaleToFit(200, 25); contentByte.AddImage(image); } if (tarAlm4.Folio.Length > 0) { image = Image.GetInstance(BarCode.EncodeBytes(tarAlm4.Folio, false, 300, 50)); image.SetAbsolutePosition(CTE_X_POS_INI + 280, CTE_HEIGHT_CONST + CTE_Y_SPACE);// set the position in the document where you want the watermark to appear (0,0 = bottom left corner of the page) //image.ScaleToFit(200, 25); contentByte.AddImage(image); } } catch { throw; } }
private static void addBarCodes(PdfStamper stamper, string folioOrdCarga) { PdfContentByte contentByte; try { contentByte = stamper.GetOverContent(1); int CTE_HEIGHT_CONST = 540; int CTE_X_POS_INI = 47; Image image = Image.GetInstance(BarCode.EncodeBytes(folioOrdCarga, false, 250, 100)); image.SetAbsolutePosition(CTE_X_POS_INI, CTE_HEIGHT_CONST);// set the position in the document where you want the watermark to appear (0,0 = bottom left corner of the page) contentByte.AddImage(image); } catch { throw; } }
private static void addBarCodes(PdfStamper stamper, Salida_remision oSR1) { //using (Stream inputPdfStream = new FileStream("input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read)) //using (Stream inputImageStream = new FileStream("some_image.jpg", FileMode.Open, FileAccess.Read, FileShare.Read)) //using (Stream outputPdfStream = new FileStream("result.pdf", FileMode.Create, FileAccess.Write, FileShare.None)) //{ // var reader = new PdfReader(inputPdfStream); // var stamper = new PdfStamper(reader, outputPdfStream); // var pdfContentByte = stamper.GetOverContent(1); // Image image = Image.GetInstance(inputImageStream); // image.SetAbsolutePosition(100, 100); // pdfContentByte.AddImage(image); // stamper.Close(); //} PdfContentByte contentByte; try { contentByte = stamper.GetOverContent(1); int CTE_HEIGHT_CONST = 400; int CTE_X_POS_INI = 35; int CTE_X_SPACE = 135; Image image = Image.GetInstance(BarCode.EncodeBytes(oSR1.Codigo, true)); image.SetAbsolutePosition(CTE_X_POS_INI, CTE_HEIGHT_CONST);// set the position in the document where you want the watermark to appear (0,0 = bottom left corner of the page) //image.ScaleToFit(200, 25); contentByte.AddImage(image); //setAbsolutePosition 54 + 127 image = Image.GetInstance(BarCode.EncodeBytes(oSR1.Orden, true)); image.SetAbsolutePosition(CTE_X_POS_INI + CTE_X_SPACE, CTE_HEIGHT_CONST);// set the position in the document where you want the watermark to appear (0,0 = bottom left corner of the page) //image.ScaleToFit(200, 25); contentByte.AddImage(image); //var fs = new BinaryWriter(new FileStream(@"C:\Documents and Settings\Gilberto\Mis documentos\Visual Studio 2010\Projects\CASC\AppCasc\rpt\" + "\\codigo2.png", FileMode.Append, FileAccess.Write)); //fs.Write(BarCode.EncodeBytes(oSR1.Vendor, true)); //fs.Close(); //181 + 127 + 127 //image = Image.GetInstance(@"C:\Documents and Settings\Gilberto\Mis documentos\Visual Studio 2010\Projects\CASC\AppCasc\rpt\codigo.png"); //image = Image.GetInstance(@"C:\Documents and Settings\Gilberto\Mis documentos\Visual Studio 2010\Projects\CASC\AppCasc\rpt\codigo2.png"); image = Image.GetInstance(BarCode.EncodeBytes(oSR1.Vendor, true)); image.SetAbsolutePosition(CTE_X_POS_INI + CTE_X_SPACE * 3, CTE_HEIGHT_CONST);// set the position in the document where you want the watermark to appear (0,0 = bottom left corner of the page) //image.ScaleToFit(200, 25); contentByte.AddImage(image, true); //Código del folio de la remisión image = Image.GetInstance(BarCode.EncodeBytes(oSR1.Folio_remision, false, 170, 40)); image.SetAbsolutePosition(CTE_X_POS_INI + CTE_X_SPACE * 3 - 40, 10); contentByte.AddImage(image); //Referencia image = Image.GetInstance(BarCode.EncodeBytes(oSR1.Referencia, false)); image.SetAbsolutePosition(CTE_X_POS_INI + CTE_X_SPACE * 3 - 10, CTE_HEIGHT_CONST + 230);// set the position in the document where you want the watermark to appear (0,0 = bottom left corner of the page) //image.ScaleToFit(200, 25); contentByte.AddImage(image); } catch { throw; } }