当前位置: 首页>>代码示例>>C#>>正文


C# PdfStamper.GetOverContent方法代码示例

本文整理汇总了C#中iTextSharp.text.pdf.PdfStamper.GetOverContent方法的典型用法代码示例。如果您正苦于以下问题:C# PdfStamper.GetOverContent方法的具体用法?C# PdfStamper.GetOverContent怎么用?C# PdfStamper.GetOverContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iTextSharp.text.pdf.PdfStamper的用法示例。


在下文中一共展示了PdfStamper.GetOverContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ManipulatePdf

// ---------------------------------------------------------------------------    
    /**
     * Manipulates a PDF file src with the file dest as result
     * @param src the original PDF
     */
    public byte[] ManipulatePdf(byte[] src) {
    // Create a table with named actions
      Font symbol = new Font(Font.FontFamily.SYMBOL, 20);
      PdfPTable table = new PdfPTable(4);
      table.DefaultCell.Border = Rectangle.NO_BORDER;
      table.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER;
      Chunk first = new Chunk( ((char)220).ToString() , symbol);
      first.SetAction(new PdfAction(PdfAction.FIRSTPAGE));
      table.AddCell(new Phrase(first));
      Chunk previous = new Chunk( ((char)172).ToString(), symbol);
      previous.SetAction(new PdfAction(PdfAction.PREVPAGE));
      table.AddCell(new Phrase(previous));
      Chunk next = new Chunk( ((char)174).ToString(), symbol);
      next.SetAction(new PdfAction(PdfAction.NEXTPAGE));
      table.AddCell(new Phrase(next));
      Chunk last = new Chunk( ((char)222).ToString(), symbol);
      last.SetAction(new PdfAction(PdfAction.LASTPAGE));
      table.AddCell(new Phrase(last));
      table.TotalWidth = 120;
      
      // Create a reader
      PdfReader reader = new PdfReader(src);
      using (MemoryStream ms = new MemoryStream()) {
        // Create a stamper
        using (PdfStamper stamper = new PdfStamper(reader, ms)) {
          // Add the table to each page
          PdfContentByte canvas;
          for (int i = 0; i < reader.NumberOfPages; ) {
            canvas = stamper.GetOverContent(++i);
            table.WriteSelectedRows(0, -1, 696, 36, canvas);
          }
        }
        return ms.ToArray();
      }    
    }    
开发者ID:,项目名称:,代码行数:40,代码来源:

示例2: ManipulatePdf

 // ---------------------------------------------------------------------------    
 /**
  * Manipulates a PDF file src with the file dest as result
  * @param src the original PDF
  */
 public byte[] ManipulatePdf(byte[] src)
 {
     // Create the reader
     PdfReader reader = new PdfReader(src);
     int n = reader.NumberOfPages;
     using (MemoryStream ms = new MemoryStream())
     {
         // Create the stamper
         using (PdfStamper stamper = new PdfStamper(reader, ms))
         {
             // Make a list with all the possible actions
             actions = new List<PdfAction>();
             PdfDestination d;
             for (int i = 0; i < n; )
             {
                 d = new PdfDestination(PdfDestination.FIT);
                 actions.Add(PdfAction.GotoLocalPage(++i, d, stamper.Writer));
             }
             // Add a navigation table to every page
             PdfContentByte canvas;
             for (int i = 0; i < n; )
             {
                 canvas = stamper.GetOverContent(++i);
                 CreateNavigationTable(i, n).WriteSelectedRows(0, -1, 696, 36, canvas);
             }
         }
         return ms.ToArray();
     }
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:34,代码来源:TimetableDestinations.cs

示例3: ManipulatePdf

 /// <summary>
 /// Fills out and flattens a form with the name, company and country.
 /// </summary>
 /// <param name="src"> the path to the original form </param>
 /// <param name="dest"> the path to the filled out form </param>
 public void ManipulatePdf(String src, String dest)
 {
     PdfReader reader = new PdfReader(src);
     PdfStamper stamper = new PdfStamper(reader, new FileStream(dest, FileMode.Create));
     int n = reader.NumberOfPages;
     Rectangle pagesize;
     for (int i = 1; i <= n; i++)
     {
         PdfContentByte over = stamper.GetOverContent(i);
         pagesize = reader.GetPageSize(i);
         float x = (pagesize.Left + pagesize.Right) / 2;
         float y = (pagesize.Bottom + pagesize.Top) / 2;
         PdfGState gs = new PdfGState();
         gs.FillOpacity = 0.3f;
         over.SaveState();
         over.SetGState(gs);
         over.SetRGBColorFill(200, 200, 0);
         ColumnText.ShowTextAligned(over, Element.ALIGN_CENTER,
             new Phrase("Watermark", new Font(Font.FontFamily.HELVETICA, 120)),
             x, y, 45);
         over.RestoreState();
     }
     stamper.Close();
     reader.Close();
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:30,代码来源:S04_CorrectedWatermark.cs

示例4: Go

        public void Go()
        {
            using (PdfReader reader = new PdfReader(GetTestReader()))
            {
                var outputFile = Helpers.IO.GetClassOutputPath(this);

                using (var stream = new FileStream(outputFile, FileMode.Create))
                {
                    using (PdfStamper stamper = new PdfStamper(reader, stream))
                    {
                        AcroFields form = stamper.AcroFields;
                        var fldPosition = form.GetFieldPositions(NAME)[0];
                        Rectangle rectangle = fldPosition.position;
                        string base64Image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
                        Regex regex = new Regex(@"^data:image/(?<mediaType>[^;]+);base64,(?<data>.*)");
                        Match match = regex.Match(base64Image);
                        Image image = Image.GetInstance(
                            Convert.FromBase64String(match.Groups["data"].Value)
                        );
                        // best fit if image bigger than form field
                        if (image.Height > rectangle.Height || image.Width > rectangle.Width)
                        {
                            image.ScaleAbsolute(rectangle);
                        }
                        // form field top left - change parameters as needed to set different position 
                        image.SetAbsolutePosition(rectangle.Left + 2, rectangle.Top - 8);
                        stamper.GetOverContent(fldPosition.page).AddImage(image);
                    }
                }
            }
        }
开发者ID:kuujinbo,项目名称:StackOverflow.iTextSharp,代码行数:31,代码来源:AddBase64Image.cs

示例5: addCompanyLogo

        private string addCompanyLogo(string pdfPath)
        {
            string outputPDFPath = null;
            int clientID = Core.SessionHelper.getClientId();

            string logoPath = string.Format("{0}/ClientLogo/{1}.jpg", ConfigurationManager.AppSettings["appPath"].ToString(), clientID);
            if (File.Exists(logoPath)) {
                outputPDFPath = string.Format("{0}/Temp/{1}.pdf", appPath, Guid.NewGuid());

                using (var inputPdfStream = new FileStream(pdfPath, FileMode.Open))

                using (var outputPdfStream = new FileStream(outputPDFPath, FileMode.Create)) {
                    PdfReader reader = new PdfReader(inputPdfStream);

                    PdfStamper stamper = new PdfStamper(reader, outputPdfStream);

                    PdfContentByte pdfContentByte = stamper.GetOverContent(1);

                    //var image = iTextSharp.text.Image.GetInstance(inputImageStream);
                    var image = iTextSharp.text.Image.GetInstance(logoPath);
                    image.ScaleToFit(100f, 100f);

                    PdfDocument doc = pdfContentByte.PdfDocument;

                    image.SetAbsolutePosition(40f, doc.PageSize.Height - 150f);
                    pdfContentByte.AddImage(image);
                    stamper.Close();
                }
            }
            else {
                outputPDFPath = pdfPath;
            }

            return outputPDFPath;
        }
开发者ID:Antoniotoress1992,项目名称:asp,代码行数:35,代码来源:PrintInvoice.aspx.cs

示例6: PDFStamp

        public static void PDFStamp(string inputPath, string outputPath, string watermarkPath)
        {
            try
            {
                PdfReader pdfReader = new PdfReader(inputPath);
                int numberOfPages = pdfReader.NumberOfPages;
                FileStream outputStream = new FileStream(outputPath, FileMode.Create);

                PdfStamper pdfStamper = new PdfStamper(pdfReader, outputStream);
                PdfContentByte waterMarkContent;

                iTextSharp.text.Rectangle psize = pdfReader.GetPageSize(1);

                float width = psize.Width;

                float height = psize.Height;

                string watermarkimagepath = watermarkPath;
                iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(watermarkimagepath);
                image.ScalePercent(70f);
                image.SetAbsolutePosition(width / 10, height / 9);

                /*                        image.ScaleAbsoluteHeight(10);
                                        image.ScaleAbsoluteW idth(10);*/

                //   waterMarkContent = pdfStamper.GetUnderContent(1);
                // waterMarkContent.AddImage(image);

                for (int i = 1; i <= numberOfPages; i++)
                {
                    //waterMarkContent = pdfStamper.GetUnderContent(i);//内容下层加水印
                    waterMarkContent = pdfStamper.GetOverContent(i);//内容上层加水印

                    waterMarkContent.AddImage(image);
                }

                pdfStamper.Close();
                pdfReader.Close();
                System.IO.File.Move(outputPath, inputPath);
            }
            catch (Exception)
            {

            }
              /*  finally
            {

                pdfStamper.Close();
                pdfReader.Close();
            }*/

            /*            System.IO.File.Delete(inputPath);

                        System.IO.File.Move(outputPath, inputPath);
                         System.IO.File.Delete(outputPath);*/
        }
开发者ID:503945930,项目名称:MvcRead,代码行数:56,代码来源:PDFSetWaterMark.cs

示例7: Stamp

// ---------------------------------------------------------------------------
    /**
     * Manipulates a PDF file src with the file dest as result
     * @param resource the original PDF
     */
    public static byte[] Stamp(byte[] resource) {
      PdfReader reader = new PdfReader(resource);
      using (var ms = new MemoryStream()) {
        using (PdfStamper stamper = new PdfStamper(reader, ms)) {
          PdfContentByte canvas = stamper.GetOverContent(1);
          ColumnText.ShowTextAligned(
            canvas,
            Element.ALIGN_LEFT, 
            new Phrase("Hello people!"), 
            36, 540, 0
          );
        }
        return ms.ToArray();
      }
    }
开发者ID:,项目名称:,代码行数:20,代码来源:

示例8: Index

        public ActionResult Index(IEnumerable<HttpPostedFileBase> files)
        {
            // image file extension check ignore for brevity
            var fileList = files.Where(h => h != null && h.ContentLength > 0);
            if (fileList.Count() < 1)
                throw new Exception("no files uploaded");

            var absoluteX = 20;
            var absoluteY = 800;
            using (var stream = new MemoryStream())
            {
                using (var stamper = new PdfStamper(Helpers.Pdf.GetTestReader(), stream))
                {
                    var pageOneSize = stamper.Reader
                        .GetPageSize(APPEND_NEW_PAGE_NUMBER - 1);
                    foreach (var file in fileList)
                    {
                        using (var br = new BinaryReader(file.InputStream))
                        {
                            var imageBytes = br.ReadBytes(file.ContentLength);
                            var image = Image.GetInstance(imageBytes);

                            // still not sure if you want to add a new blank page, but 
                            // here's how
                            stamper.InsertPage(
                                APPEND_NEW_PAGE_NUMBER,
                                pageOneSize
                            );

                            // image absolute position
                            image.SetAbsolutePosition(
                                absoluteX, absoluteY - image.Height
                            );

                            // scale image if needed
                            // image.ScaleAbsolute(...);

                            // PAGE_NUMBER => add image to specific page number
                            stamper.GetOverContent(APPEND_NEW_PAGE_NUMBER)
                                .AddImage(image);
                        }
                        ++APPEND_NEW_PAGE_NUMBER;
                    }
                }
                return File(stream.ToArray(), "application/pdf", "test.pdf");
            }
        }
开发者ID:kuujinbo,项目名称:StackOverflow.iTextSharp.MVC,代码行数:47,代码来源:UploadMultipleImagesController.cs

示例9: Highlight

 /// <summary>
 /// Accepts a list of MyItem objects and draws a colored rectangle for each
 /// item in the list.
 /// </summary>
 /// <param name="items">The list of items</param>
 /// <param name="reader">The reader instance that has access to the PDF file</param>
 /// <param name="pageNum">The page number of the page that needs to be parsed</param>
 /// <param name="destination">The path for the altered PDF file</param>
 public void Highlight(List<MyItem> items, PdfReader reader, int pageNum, String destination)
 {
     PdfStamper stamper = new PdfStamper(reader, new FileStream(destination, FileMode.Create));
     PdfContentByte over = stamper.GetOverContent(pageNum);
     foreach (MyItem item in items)
     {
         if (item.Color == null)
             continue;
         over.SaveState();
         over.SetColorStroke(item.Color);
         over.SetLineWidth(2);
         Rectangle r = item.Rectangle;
         over.Rectangle(r.Left, r.Bottom, r.Width, r.Height);
         over.Stroke();
         over.RestoreState();
     }
     stamper.Close();
 }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:26,代码来源:S08_FindItems.cs

示例10: ManipulatePdf

 public void ManipulatePdf(string src, string dest)
 {
     PdfReader reader = new PdfReader(src);
     // We assume that there's a single large picture on the first page
     PdfDictionary page = reader.GetPageN(1);
     PdfDictionary resources = page.GetAsDict(PdfName.RESOURCES);
     PdfDictionary xobjects = resources.GetAsDict(PdfName.XOBJECT);
     Dictionary<PdfName, PdfObject>.KeyCollection.Enumerator enumerator = xobjects.Keys.GetEnumerator();
     enumerator.MoveNext();
     PdfName imgName = enumerator.Current;
     Image img = Image.GetInstance((PRIndirectReference) xobjects.GetAsIndirectObject(imgName));
     img.SetAbsolutePosition(0, 0);
     img.ScaleAbsolute(reader.GetPageSize(1));
     PdfStamper stamper = new PdfStamper(reader, new FileStream(dest,FileMode.Create));
     stamper.GetOverContent(1).AddImage(img);
     stamper.Close();
     reader.Close();
 }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:18,代码来源:RepeatImage.cs

示例11: ManipulatePdf

 // ---------------------------------------------------------------------------
 /**
  * Manipulates a PDF file src with the file dest as result (localhost)
  * @param src the original PDF
  */
 public byte[] ManipulatePdf(byte[] src)
 {
     // Create the reader
     PdfReader reader = new PdfReader(src);
     int n = reader.NumberOfPages;
     using (MemoryStream ms = new MemoryStream())
     {
         // Create the stamper
         using (PdfStamper stamper = new PdfStamper(reader, ms))
         {
             // Add JavaScript
             jsString = File.ReadAllText(
               Path.Combine(Utility.ResourceJavaScript, RESOURCE)
             );
             stamper.JavaScript = jsString;
             // Create a Chunk with a chained action
             PdfContentByte canvas;
             Chunk chunk = new Chunk("print this page");
             PdfAction action = PdfAction.JavaScript(
               "app.alert('Think before you print!');",
               stamper.Writer
             );
             action.Next(PdfAction.JavaScript(
               "printCurrentPage(this.pageNum);",
               stamper.Writer
             ));
             action.Next(new PdfAction("http://www.panda.org/savepaper/"));
             chunk.SetAction(action);
             Phrase phrase = new Phrase(chunk);
             // Add this Chunk to every page
             for (int i = 0; i < n; )
             {
                 canvas = stamper.GetOverContent(++i);
                 ColumnText.ShowTextAligned(
                   canvas, Element.ALIGN_RIGHT, phrase, 816, 18, 0
                 );
             }
         }
         return ms.ToArray();
     }
 }
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:46,代码来源:PrintTimeTable.cs

示例12: ParseAndHighlight

        private void ParseAndHighlight(String input, String output, bool singleCharacters) {
            PdfReader reader = new PdfReader(input);
            FileStream fos = new FileStream(output, FileMode.Create);
            PdfStamper stamper = new PdfStamper(reader, fos);

            PdfReaderContentParser parser = new PdfReaderContentParser(reader);
            MyRenderListener myRenderListener = singleCharacters ? new MyCharacterRenderListener() : new MyRenderListener();
            for (int pageNum = 1; pageNum <= reader.NumberOfPages; pageNum++) {
                List<Rectangle> rectangles = parser.ProcessContent(pageNum, myRenderListener).GetRectangles();
                PdfContentByte canvas = stamper.GetOverContent(pageNum);
                canvas.SetLineWidth(0.5f);
                canvas.SetColorStroke(BaseColor.RED);
                foreach (Rectangle rectangle in rectangles) {
                    canvas.Rectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, rectangle.Height);
                    canvas.Stroke();
                }
            }
            stamper.Close();
            fos.Close();
            reader.Close();
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:21,代码来源:HighlightItemsTest.cs

示例13: Write

// --------------------------------------------------------------------------- 
    public void Write(Stream stream) {
      using (ZipFile zip = new ZipFile()) {
        zip.AddFile(PREFACE, "");
        PdfReader reader = new PdfReader(PREFACE);
        PdfReaderContentParser parser = new PdfReaderContentParser(reader);
        using (MemoryStream ms = new MemoryStream()) {
          using (PdfStamper stamper = new PdfStamper(reader, ms)) {
            TextMarginFinder finder;
            for (int i = 1; i <= reader.NumberOfPages; i++) {
              finder = parser.ProcessContent(i, new TextMarginFinder());
              PdfContentByte cb = stamper.GetOverContent(i);
              cb.Rectangle(
                finder.GetLlx(), finder.GetLly(),
                finder.GetWidth(), finder.GetHeight()
              );
              cb.Stroke();
            }
          }
          zip.AddEntry(RESULT, ms.ToArray());
        }
        zip.Save(stream);             
      }
    }
开发者ID:,项目名称:,代码行数:24,代码来源:

示例14: CreateCompanyRegistrationDocument

        public MemoryStream CreateCompanyRegistrationDocument(string fileName, string companyName, string companyNumber)
        {
            using (var stumpedDocStream = new MemoryStream())
            {
                PdfReader reader = null;
                PdfStamper stamper = null;
                try
                {
                    reader = new PdfReader(fileName);
                    stamper = new PdfStamper(reader, stumpedDocStream);
                    var bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                    var font = new Font(bf, textSize);
                    for (var pageNumber = 1; pageNumber < reader.NumberOfPages + 1; pageNumber++)
                    {
                        var canvas = stamper.GetOverContent(pageNumber);
                        canvas.SetFontAndSize(bf, textSize);
                        RenderPhase(pageNumber, companyNameLocations, canvas, companyName, font);
                        RenderPhase(pageNumber, companyNumberLocations, canvas, companyNumber, font);
                    }
                }
                finally
                {
                    try
                    {
                        if(reader!=null)
                            reader.Close();
                    }
                    finally
                    {
                        if (stamper != null)
                            stamper.Close();
                    }
                }

                return new MemoryStream(EncryptPdf(stumpedDocStream.ToArray()));
            }
        }
开发者ID:oleksiyo,项目名称:PdfExamples,代码行数:37,代码来源:PdfDocumentWriter.cs

示例15: AsistenciaLegal

        public AsistenciaLegal(AufenPortalReportesDataContext db, EMPRESA empresa, vw_Ubicacione departamento, DateTime FechaDesde, DateTime FechaHasta, string path, string rut)
        {
            // Vamos a buscar los datos que nos permitirtán armar elreporte
            NombreArchivo = String.Format("{0}/{1}/LibroAtrasos.pdf", empresa.Descripcion, departamento.Descripcion);
            //Resultado de marcas
             IEnumerable<sp_LibroAsistenciaResult> resultadoLibroAtrasos =
                                           db.sp_LibroAsistencia(
                                           FechaDesde.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture),
                                           FechaHasta.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture),
                                           int.Parse(empresa.Codigo).ToString(),
                                           departamento.Codigo,
                                           rut).ToList();
             IEnumerable<LibroAsistenciaDTO> resultado = Mapper.Map<IEnumerable<sp_LibroAsistenciaResult>,
             IEnumerable<LibroAsistenciaDTO>>(resultadoLibroAtrasos);
            // Resumen de inasistencias
             IEnumerable<sp_LibroInasistenciaResult> resultadoLibroInasistencias =
                 db.sp_LibroInasistencia(FechaDesde.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture)
                    , FechaHasta.ToString("yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture)
                    , int.Parse(empresa.Codigo).ToString()
                    , departamento.Codigo
                    , rut);

            IEnumerable<LibroInasistenciaDTO> resultadoInasistencia = Mapper.Map<IEnumerable<sp_LibroInasistenciaResult>,
                 IEnumerable<LibroInasistenciaDTO>>(resultadoLibroInasistencias);
             if (resultadoLibroAtrasos.Any())
             {
                 string[] diasSemana = new[] { "dom", "lun", "mar", "mie", "ju", "vie", "sab" };
                 using (MemoryStream finalStream = new MemoryStream())
                 {
                     PdfCopyFields copy = new PdfCopyFields(finalStream);
                     foreach (var reporte in resultado.Where(x => x.Rut != null).GroupBy(x => new
                     {
                         x.Rut,
                         x.IdEmpresa,
                         x.IdDepartamento,
                         Mes = x.Fecha.Value.Month,
                         Anio = x.Fecha.Value.Year
                     }))
                     {
                         var inasistencias = resultadoInasistencia.Where(x => x.Rut!= null &&
                             x.Rut == reporte.Key.Rut &&
                             x.IdEmpresa == reporte.Key.IdEmpresa &&
                             x.IdDepartamento == reporte.Key.IdDepartamento &&
                            reporte.Key.Mes == x.Fecha.Value.Month &&
                            reporte.Key.Anio == x.Fecha.Value.Year);
                         var empleado = db.vw_Empleados.FirstOrDefault(x => x.IdEmpresa == empresa.Codigo &&
                             x.IdUbicacion == reporte.Key.IdDepartamento &&
                                  x.Codigo == reporte.Key.Rut);
                         int numeroSemanas = reporte.Max(x => x.NumSemana) == 6 ? 6 : 5;
                         using (MemoryStream ms = new MemoryStream())
                         {
                             using (PdfReader pdfReader = new PdfReader(path + String.Format(@"\ReporteAsistenciaLegal{0}.pdf",  numeroSemanas)))
                             {
                                 DateTime fechaReferencia = reporte.First().Fecha.Value;
                                 DateTime primerDiaMes = new DateTime(fechaReferencia.Year, fechaReferencia.Month, 1);
                                 DateTime ultimoDiaMes = primerDiaMes.AddMonths(1).AddSeconds(-1);
                                 PdfStamper pdfStamper = new PdfStamper(pdfReader, ms);

                                 int PageCount = pdfReader.NumberOfPages;
                                 for (int x = 1; x <= PageCount; x++)
                                 {
                                     PdfContentByte cb = pdfStamper.GetOverContent(x);
                                     Image imagen = Image.GetInstance(String.Format(@"{0}\imagenes\LogosEmpresas\logo{1}.jpg", path, empresa.Codigo.Trim()));
                                     imagen.ScaleToFit(100, 200);
                                     imagen.SetAbsolutePosition(450, 750);
                                     cb.AddImage(imagen);
                                 }

                                 pdfStamper.AcroFields.SetField("Mes", new DateTime(reporte.Key.Anio, reporte.Key.Mes, 1).ToString("yyyy MMM"));
                                 pdfStamper.AcroFields.SetField("Nombre", empleado != null ? empleado.NombreCompleto : String.Empty);
                                 pdfStamper.AcroFields.SetField("Rut", empleado.RutAufen);
                                 pdfStamper.AcroFields.SetField("Departamento", String.Format("{0} ({1})", departamento!= null ? departamento.SucursalPlanta : String.Empty, empresa!=null ? empresa.Descripcion.Trim() : String.Empty));
                                 pdfStamper.AcroFields.SetField("Fecha", String.Format("{0} - {1}", primerDiaMes.ToShortDateString(), ultimoDiaMes.ToShortDateString()));
                                 pdfStamper.AcroFields.SetField("ImpresoPagina1", DateTime.Now.ToShortDateString());
                                 pdfStamper.AcroFields.SetField("ImpresoPagina2", DateTime.Now.ToShortDateString());
                                 pdfStamper.AcroFields.SetField("UsuarioPagina1", "");
                                 pdfStamper.AcroFields.SetField("UsuarioPagina2", "");
                                 //Para todas las semanas
                                 for (int i = 1; i <=  numeroSemanas; i++)
                                 {
                                     //Para todos los días de la semana
                                     var semana = reporte.Where(x => x.NumSemana == i);
                                     for (int j = 0; j <= 6; j++)
                                     {
                                        // Si se elimina esto el domingo va aquedar al final
                                        int correccionDia = j;//j == 6 ? 0 : j + 1;
                                         var dia = reporte.FirstOrDefault(x => x.NumSemana == i && (int)x.Fecha.Value.DayOfWeek == j);
                                         //
                                         pdfStamper.AcroFields.SetField(String.Format("Semana{0}Tipo{1}", i, correccionDia),
                                             String.Format("{0}\n{1}",
                                                String.Format("{0}-{1}", dia!= null && dia.Entrada.HasValue ? dia.Entrada.Value.ToString("HH:mm") : String.Empty
                                                    , dia!=null && dia.Salida.HasValue ? dia.Salida.Value.ToString("HH:mm") : String.Empty),
                                                dia != null ? dia.Observacion : String.Empty));
                                        pdfStamper.AcroFields.SetField(String.Format("Semana{0}Dia{1}", i, correccionDia), String.Format("{0} {1}", dia != null ? dia.Fecha.Value.ToString("dd/MM") : string.Empty, diasSemana[j]));
                                     }
                                     // Semana a semana
                                     pdfStamper.AcroFields.SetField(String.Format("Semana{0}Jornada", i), semana.CalculaJornada());
                                     pdfStamper.AcroFields.SetField(String.Format("Semana{0}Asistencia", i), semana.CalculaAsistencia());

                                     //  T. de Salida = inasistencia justifica
//.........这里部分代码省略.........
开发者ID:LazyAbstract,项目名称:AReportes,代码行数:101,代码来源:AsistenciaLegal.cs


注:本文中的iTextSharp.text.pdf.PdfStamper.GetOverContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。