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


C# Document.AddCreationDate方法代码示例

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


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

示例1: ReportPdf

        public ReportPdf(Stream Output, Layout Layout, Template Template, Dictionary<string, string> ConfigParams)
            : base(Output, Layout, Template, ConfigParams)
        {
            Rectangle pageSize = new Rectangle(mm2pt(Template.PageSize.Width), mm2pt(Template.PageSize.Height));

            // Initialization
            m_Document = new Document(pageSize, mm2pt(Template.Margin.Left), mm2pt(Template.Margin.Right), mm2pt(Template.Margin.Top), mm2pt(Template.Margin.Bottom));
            m_Writer = PdfWriter.GetInstance(m_Document, Output);

            m_Document.AddCreationDate();
            m_Document.AddCreator("StrengthReport http://dev.progterv.info/strengthreport) and KeePass (http://keepass.info)");
            m_Document.AddKeywords("report");
            m_Document.AddTitle(Layout.Title+" (report)");

            // Header
            HeaderFooter header = new HeaderFooter(new Phrase(Layout.Title+", "+DateTime.Now.ToString(), m_Template.ReportFooter.getFont()), false);
            header.Alignment = Template.ReportFooter.getAlignment();
            m_Document.Header = header;

            // Footer
            HeaderFooter footer = new HeaderFooter(new Phrase(new Chunk("Page ", m_Template.ReportFooter.getFont())), new Phrase(new Chunk(".", m_Template.ReportFooter.getFont())));
            footer.Alignment = Template.ReportFooter.getAlignment();
            m_Document.Footer = footer;

            // TODO: Metadata
            // Open document
            m_Document.Open();

            // Report Heading
            {
                PdfPTable reportTitle = new PdfPTable(1);
                PdfPCell titleCell = new PdfPCell(new Phrase(Layout.Title, m_Template.ReportHeader.getFont()));
                titleCell.Border = 0;
                titleCell.FixedHeight = mm2pt(m_Template.ReportHeader.Height);
                titleCell.VerticalAlignment = Element.ALIGN_MIDDLE;
                titleCell.HorizontalAlignment = m_Template.ReportHeader.getAlignment();
                reportTitle.AddCell(titleCell);
                reportTitle.WidthPercentage = 100;
                m_Document.Add(reportTitle);
            }

            // Create main table
            m_Table = new PdfPTable(Layout.GetColumnWidths());
            m_Table.WidthPercentage = 100;
            m_Table.HeaderRows = 1;
            foreach (LayoutElement element in Layout) {
                PdfPCell cell = new PdfPCell(new Phrase(element.Title, m_Template.Header.getFont()));
                cell.BackgroundColor = m_Template.Header.Background.ToColor();
                cell.MinimumHeight = mm2pt(m_Template.Header.Height);
                cell.VerticalAlignment = Element.ALIGN_MIDDLE;
                m_Table.AddCell(cell);
            }

            m_colorRow = new CMYKColor[] { m_Template.Row.BackgroundA.ToColor(), m_Template.Row.BackgroundB.ToColor() };
        }
开发者ID:jonbws,项目名称:strengthreport,代码行数:55,代码来源:ReportPdf.cs

示例2: RenderAllTables

        /// <summary>
        /// Render all data add and writes it to the specified writer
        /// </summary>
        /// <param name="model">
        /// The model to render
        /// </param>
        /// <param name="os">
        /// The output to write to
        /// </param>
        public override void RenderAllTables(IDataSetModel model, Stream os)
        {
            // TODO check the number of horizontal & vertical key values to determine the orientation of the page
            var doc = new Document(this._pageSize, 80, 50, 30, 65);

            // This doesn't seem to do anything...
            doc.AddHeader(Markup.HTML_ATTR_STYLESHEET, "style/pdf.css");
            doc.AddCreationDate();
            doc.AddCreator("NSI .NET Client");
            try
            {
                PdfWriter.GetInstance(doc, os);
                doc.Open();
                this.WriteTableModels(model, doc);
            }
            catch (DocumentException ex)
            {
                Trace.Write(ex.ToString());
                LogError.Instance.OnLogErrorEvent(ex.ToString());
            }
            catch (DbException ex)
            {
                Trace.Write(ex.ToString());
                LogError.Instance.OnLogErrorEvent(ex.ToString());
            }
            finally
            {
                if (doc.IsOpen())
                {
                    doc.Close();
                }
            }
        }
开发者ID:alcardac,项目名称:SDMX_DATA_BROWSER,代码行数:42,代码来源:PdfRenderer.cs

示例3: PDFDocument

		public PDFDocument(Stream stream, Rectangle pageSize)
		{
			DocumentStream = stream;
			Document = new Document(pageSize);
			PageEventHelper = new PageEventHelper();
			Writer = PdfWriter.GetInstance(Document, stream);
			Writer.PageEvent = PageEventHelper;
			Document.Open();
			Document.AddCreationDate();
		}
开发者ID:saeednazari,项目名称:Rubezh,代码行数:10,代码来源:PDFDocument.cs

示例4: WriteDocument

        protected override void WriteDocument(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            if (File.Exists(FilePath))
                throw new Pdf2KTException("File already exists.");

            Document document = null;
            PdfWriter writer = null;

            while(Converter.MoveNext())
            {
                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }

                BitmapEncoder encoder = BitmapProcessor.GetBitmapEncoder();
                BitmapSource processed = BitmapProcessor.Convert(Converter.Current);

                if (document == null)
                {
                    document = new Document(new Rectangle(processed.PixelWidth, processed.PixelHeight));
                    writer = PdfWriter.GetInstance(document, new FileStream(FilePath, FileMode.Create));

                    document.Open();
                    document.AddTitle(Converter.Document.Title);
                    document.AddAuthor(Converter.Document.Author);
                    document.AddCreationDate();
                    document.AddCreator("Pdf2KT");
                }

                document.NewPage();

                using (MemoryStream ms = new MemoryStream())
                {
                    encoder.Frames.Add(BitmapFrame.Create(processed));
                    encoder.Save(ms);

                    ms.Position = 0;

                    Image pdfpage = Image.GetInstance(ms);
                    pdfpage.SetAbsolutePosition(0, 0);

                    document.Add(pdfpage);
                }

                worker.ReportProgress((int)((Converter.CurrentProcessedPageNumber * 1f) / Converter.PageCount * 100));
            }

            document.Close();
        }
开发者ID:skpdvdd,项目名称:Pdf2KT,代码行数:53,代码来源:PDFWriter.cs

示例5: GeneratePDF

        public static MemoryStream GeneratePDF(Teacher teacher, SchoolClass schoolClass, string schoolYear)
        {
            Document document = new Document();
            MemoryStream stream = new MemoryStream();
            PdfWriter writer = PdfWriter.GetInstance(document, stream);

            writer.CloseStream = false;
            document.Open();
            document.AddCreationDate();
            document.AddAuthor("VaKEGrade");
            document.AddTitle("Certificate");

            foreach (Pupil pupil in teacher.PrimaryClasses.First().Pupils.OrderBy(x => x.LastName).ToList())
            {
                CertificateGenerator.GenerateCertificate(pupil, schoolClass, schoolYear, ref document);
            }
            document.Close();
            stream.Seek(0, SeekOrigin.Begin);
            return stream;
        }
开发者ID:pranabnth,项目名称:vakegrade,代码行数:20,代码来源:CertificateGenerator.cs

示例6: Initialize

        public override void Initialize()
        {
            // step 1 : creation of document object
            Rectangle rect = new Rectangle((float)bbox.Width * 1.1f, (float)bbox.Height * 1.1f);
            rect.BackgroundColor = BaseColor.WHITE;
            _pdfDocument = new iTextSharp.text.Document(rect);
            // step 2:
            // we create a writer that listens to the document
            // and directs a PDF-stream to a file
            PdfWriter writer = PdfWriter.GetInstance(_pdfDocument, _stream);
            // step 3: we open the document
            _pdfDocument.Open();
            // step 4: we add content to the document
            _pdfDocument.AddCreationDate();
            _pdfDocument.AddAuthor(author);
            _pdfDocument.AddTitle(title);

            _cb = writer.DirectContent;

            // initialize cotation
            PicCotation._globalCotationProperties._arrowLength = bbox.Height / 50.0;
        }
开发者ID:minrogi,项目名称:PLMPack,代码行数:22,代码来源:PicGraphicsPdf.cs

示例7: To_pdf

        private void To_pdf()
        {
            Document doc = new Document(PageSize.A4.Rotate(), 10, 10, 10, 10);
                    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                    saveFileDialog1.InitialDirectory = @"C:";
                    saveFileDialog1.Title = "Guardar Reporte";
                    saveFileDialog1.DefaultExt = "pdf";
                    saveFileDialog1.Filter = "pdf Files (*.pdf)|*.pdf| All Files (*.*)|*.*";
                    saveFileDialog1.FilterIndex = 2;
                    saveFileDialog1.RestoreDirectory = true;
                    string filename = "";
                    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                    {
                        filename = saveFileDialog1.FileName;
                    }

                    if (filename.Trim() != "")
                    {
                        FileStream file = new FileStream(filename,
                        FileMode.OpenOrCreate,
                        FileAccess.ReadWrite,
                        FileShare.ReadWrite);
                        PdfWriter.GetInstance(doc, file);
                        doc.Open();
                        string remito = "Autorizo: OSVALDO SANTIAGO ESTRADA";
                        string envio = "Fecha:" + DateTime.Now.ToString();

                        Chunk chunk = new Chunk("Reporte de General Usuarios", FontFactory.GetFont("ARIAL", 20, iTextSharp.text.Font.BOLD));
                        doc.Add(new Paragraph(chunk));
                        doc.Add(new Paragraph("                       "));
                        doc.Add(new Paragraph("                       "));
                        doc.Add(new Paragraph("------------------------------------------------------------------------------------------"));
                        doc.Add(new Paragraph("Lagos de moreno Jalisco"));
                        doc.Add(new Paragraph(remito));
                        doc.Add(new Paragraph(envio));
                        doc.Add(new Paragraph("------------------------------------------------------------------------------------------"));
                        doc.Add(new Paragraph("                       "));
                        doc.Add(new Paragraph("                       "));
                        doc.Add(new Paragraph("                       "));
                        GenerarDocumento(doc);
                        doc.AddCreationDate();
                        doc.Add(new Paragraph("______________________________________________", FontFactory.GetFont("ARIAL", 20, iTextSharp.text.Font.BOLD)));
                        doc.Add(new Paragraph("Firma", FontFactory.GetFont("ARIAL", 20, iTextSharp.text.Font.BOLD)));
                        doc.Close();
                        Process.Start(filename);//Esta parte se puede omitir, si solo se desea guardar el archivo, y que este no se ejecute al instante
                    }
        }
开发者ID:Warrior6021,项目名称:ReportesItextSharp,代码行数:47,代码来源:Form1.cs

示例8: PDF

        //Export PDF des statistiques
        public ActionResult PDF()
        {
            List<Stat> stats = context.Stats.OrderBy(i => i.form.Title).ToList();

            //Appel fonction tri stats
            ArrayList listStats = EnleveDoublonPlusComptage(stats);

            //Si erreur, redirection page erreur
            if(listStats == null)
            {
                RedirectToAction("Error", "Shared", "");
            }

            Document myDocument = new Document(PageSize.A4);
            PdfWriter.GetInstance(myDocument, new FileStream("C:\\wamp\\www\\FormOnline\\FormOnline\\docs\\Export.pdf", FileMode.Create));
            myDocument.Open();

            #region Entetes

            myDocument.AddAuthor("FormOnline");
            myDocument.AddCreationDate();
            myDocument.AddTitle("Export PDF des statistiques");

            #endregion

            PdfPTable table = new PdfPTable(4);

            //Entetes table
            PdfPCell cell = new PdfPCell(new Phrase("Export PDF des statistiques"));
            cell.Colspan = 4;
            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            cell.BackgroundColor = BaseColor.LIGHT_GRAY;

            table.AddCell(cell);
            table.AddCell("Formulaire");
            table.AddCell("Question");
            table.AddCell("Réponse");
            table.AddCell("Nb");

            int cpt = 0;

            //Pour chaque stats
            foreach (object[] obj in listStats)
            {
                PdfPCell cellF = new PdfPCell(new Phrase(obj[0].ToString()));
                PdfPCell cellQ = new PdfPCell(new Phrase(obj[1].ToString()));
                PdfPCell cellA = new PdfPCell(new Phrase(obj[2].ToString()));
                PdfPCell cellNb = new PdfPCell(new Phrase(obj[3].ToString()));

                //Effet de style 1 ligne sur 2
                if (cpt % 2 == 0)
                {
                    cellF.BackgroundColor = BaseColor.LIGHT_GRAY;
                    cellQ.BackgroundColor = BaseColor.LIGHT_GRAY;
                    cellA.BackgroundColor = BaseColor.LIGHT_GRAY;
                    cellNb.BackgroundColor = BaseColor.LIGHT_GRAY;
                }

                table.AddCell(cellF);
                table.AddCell(cellQ);
                table.AddCell(cellA);
                table.AddCell(cellNb);

                cpt++;
            }

            myDocument.Add(table);
            myDocument.Close();

            ViewData["listStats"] = listStats;

            //Retourne à la page index des stats
            return View("Index",stats);
        }
开发者ID:nikosFram,项目名称:FormOnline,代码行数:75,代码来源:StatController.cs

示例9: PDFStatQuestion

        public ActionResult PDFStatQuestion(int id)
        {
            List<Stat> stats = context.Stats.Where(i => i.QuestionId == id).ToList();

            //On récupère les infos sur la question
            Question question = context.Questions.Find(id);
            ViewData["Question"] = question;

            //
            ArrayList listStatQuestion = new ArrayList();

            foreach (var answer in question.Answers)
            {
                object[] obj = new object[] { answer.AnswerLabel, 0 };
                listStatQuestion.Add(obj);
            }

            foreach (var stat in stats)
            {
                foreach (object[] obj in listStatQuestion)
                {
                    if (obj[0] == stat.answer.AnswerLabel)
                    {
                        obj[1] = Convert.ToInt32(obj[1]) + 1;
                        break;
                    }
                }
            }

            //Affichage PDF
            Document myDocument = new Document(PageSize.A4);
            PdfWriter.GetInstance(myDocument, new FileStream("C:\\wamp\\www\\FormOnline\\FormOnline\\docs\\ExportStatQuestion" +  question.QuestionId + ".pdf", FileMode.Create));
            myDocument.Open();

            #region Entetes

            myDocument.AddAuthor("FormOnline");
            myDocument.AddCreationDate();
            myDocument.AddTitle("Export PDF des statistiques questions");

            #endregion

            PdfPTable table = new PdfPTable(2);

            //Entetes table
            PdfPCell cell = new PdfPCell(new Phrase("Export PDF des statistiques de la question : " + question.QuestionLabel));
            cell.Colspan = 2;
            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            cell.BackgroundColor = BaseColor.LIGHT_GRAY;

            PdfPCell cellForm = new PdfPCell(new Phrase("Formulaire : " + question.form.Title));
            cellForm.Colspan = 2;
            cellForm.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right

            PdfPCell cellQuest = new PdfPCell(new Phrase("Question : " + question.QuestionLabel));
            cellQuest.Colspan = 2;
            cellQuest.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            cellQuest.BackgroundColor = BaseColor.LIGHT_GRAY;

            table.AddCell(cell);
            table.AddCell(cellForm);
            table.AddCell(cellQuest);
            table.AddCell("Réponse");
            table.AddCell("Nb");

            int cpt = 0;

            //Pour chaque stats
            foreach (object[] obj in listStatQuestion)
            {
                PdfPCell cellA = new PdfPCell(new Phrase(obj[0].ToString()));
                PdfPCell cellNb = new PdfPCell(new Phrase(obj[1].ToString()));

                //Effet de style 1 ligne sur 2
                if (cpt % 2 == 0)
                {
                    cellA.BackgroundColor = BaseColor.LIGHT_GRAY;
                    cellNb.BackgroundColor = BaseColor.LIGHT_GRAY;
                }
                table.AddCell(cellA);
                table.AddCell(cellNb);

                cpt++;
            }

            myDocument.Add(table);
            myDocument.Close();

            ViewData["listStatQuestion"] = listStatQuestion;

            //Retourne à la page index des stats
            return RedirectToAction("StatQuestion", "Stat", new { id = question.QuestionId });
        }
开发者ID:nikosFram,项目名称:FormOnline,代码行数:93,代码来源:StatController.cs

示例10: Prepare_Print


//.........这里部分代码省略.........
        foreach (String weekDay in weekDays)
        {
            tempCell[rowIndex] = new PdfPCell[10];
            tempRow[rowIndex] = new PdfPRow(tempCell[rowIndex]);
            foreach (int session in sessions)
            {
                if (session == 0 || session == 6)
                {
                    if (session == 0)
                    {
                        dayPara = new Paragraph(weekDays[rowIndex],day_session_para);
                        tempCell[rowIndex][cellIndex] = new PdfPCell(dayPara);
                    }
                    else
                        if (weekDay != " ")
                        {
                            tempCell[rowIndex][cellIndex] = new PdfPCell(lunch);
                        }
                        else
                        {
                            //tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(Convert.ToString(sessions[cellIndex])));
                            dayPara = new Paragraph(Convert.ToString(sessions[cellIndex]), day_session_para);
                            tempCell[rowIndex][cellIndex] = new PdfPCell(dayPara);
                        }
                }
                else
                {
                    if (weekDay == " ")
                    {
                        dayPara = new Paragraph(Convert.ToString(sessions[cellIndex]), day_session_para);
                        tempCell[rowIndex][cellIndex] = new PdfPCell(dayPara);
                        //tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(Convert.ToString(sessions[cellIndex])));
                    }
                    else
                    {
                        string query = "select B.CourseTitle,A.TeacherID from tblStudentCourseMap as A,tblCourses as B where A.ComCod = B.ComCod and A.DaySession = '" + weekDay + session + "' and A.StudentID = '" + Current_User_ID + "'";
                        myCon.ConOpen();
                        SqlDataReader sessionDet = myCon.ExecuteReader(query);

                        if (sessionDet.Read())
                            if (!sessionDet.IsDBNull(0))
                            {
                                sessionPara = new Paragraph(sessionDet.GetString(0), session_font);
                                //tempCell[rowIndex][cellIndex] = new PdfPCell(sessionPara);
                                teacherPara = new Paragraph(sessionDet.GetString(1), teacher_font);
                                tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(sessionPara));
                                tempCell[rowIndex][cellIndex].Phrase.Add(new Phrase("\n"));
                                tempCell[rowIndex][cellIndex].Phrase.Add(teacherPara);
                                //tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(sessionDet.GetString(0) + "\n" + sessionDet.GetString(1)));
                            }
                            else
                            {
                                tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(""));
                                //tempCell[rowIndex][cellIndex
                            }
                        else
                            tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(""));
                        myCon.ConClose();
                        tempCell[rowIndex][cellIndex].FixedHeight = 75;
                    }

                }

                //tempCell[rowIndex][cellIndex].Width = 50;
                cellIndex++;
                //tempRow[rowIndex].Cells.Add(tempCell[cellIndex++, rowIndex]);
            }
            cellIndex = 0;
            //rowIndex++;
            tblSchedule.Rows.Add(tempRow[rowIndex++]);
        }

        Font HeaderFont = new Font();
        Font HeadingFont = new Font();
        HeaderFont.Size = 20;
        HeaderFont.SetStyle(Font.UNDERLINE);
        HeadingFont.Size = 15;
        HeadingFont.SetStyle(Font.UNDERLINE);
        Paragraph HeaderPara = new Paragraph("BITS PILANI, DUBAI OFFCAMPUS - TIMETABLE", HeaderFont);
        Paragraph HeadingPara = new Paragraph("Time Table allotment for " + Current_User_ID + ".",HeadingFont);
        HeaderPara.Alignment = HeadingPara.Alignment = 1;

        Document rptTimetable = new Document(PageSize.A4_LANDSCAPE.Rotate());
        PdfWriter.GetInstance(rptTimetable, new FileStream(Request.PhysicalApplicationPath + "\\" + Current_User_ID + "_timetable.pdf", FileMode.Create));
        rptTimetable.Open();
        rptTimetable.AddCreationDate();
        rptTimetable.AddHeader("BITS PILANI, DUBAI OFFCAMPUS", "TIMETABLE");
        rptTimetable.Add(new Paragraph("\n"));
        rptTimetable.AddTitle("BITS PILANI, DUBAI OFFCAMPUS - TIMETABLE");
        rptTimetable.Add(HeaderPara);
        rptTimetable.Add(HeadingPara);
        rptTimetable.Add(new Paragraph("\n\n"));

        if (rptTimetable != null && tblSchedule != null)
        {
            rptTimetable.Add(tblSchedule);
        }
        rptTimetable.Close();
        Response.Redirect("~\\" + Current_User_ID + "_timetable.pdf");
    }
开发者ID:kannan4355,项目名称:TimeTableManagementSystem,代码行数:101,代码来源:StudentHome.aspx.cs

示例11: generarPdf


//.........这里部分代码省略.........
                    else
                    {
                        sbConfigFact.
                            Append("SELECT rutaTemplateHeader, rutaTemplateFooter, @4 AS rutaLogo, objDesc, posX, posY, fontSize, dbo.convertNumToTextFunction( @2, @3) AS cantidadLetra, ").
                            Append("logoPosX, logoPosY, headerPosX, headerPosY, footerPosX, footerPosY, conceptosColWidth, desgloseColWidth ").
                            Append("FROM configuracionFacturas CF ").
                            Append("LEFT OUTER JOIN sucursales S ON S.idSucursal = @0 ").
                            Append("LEFT OUTER JOIN configuracionFactDet CFD ON CF.idConFact = CFD.idConFact ").
                            Append("WHERE CF.ST = 1 AND CF.idEmpresa = -1 AND CF.idTipoComp = @1 AND idCFDProcedencia = 1 AND objDesc NOT LIKE 'nuevoLbl%' ");
                    }
                }
                else
                {
                    sbConfigFact.
                        Append("DECLARE @idEmpresa AS INT;").
                        Append("IF EXISTS (SELECT * FROM configuracionFacturas WHERE idEmpresa = @7) ").
                        Append("SET @idEmpresa = @7; ").
                        Append("ELSE ").
                        Append("SET @idEmpresa = 0; ").
                        Append("SELECT rutaTemplateHeader, rutaTemplateFooter, S.rutaLogo, objDesc, posX, posY, fontSize, dbo.convertNumToTextFunction( @2, @3) AS cantidadLetra, ").
                        Append("logoPosX, logoPosY, headerPosX, headerPosY, footerPosX, footerPosY, conceptosColWidth, desgloseColWidth, S.nombreSucursal ").
                        Append("FROM configuracionFacturas CF ").
                        Append("LEFT OUTER JOIN sucursales S ON S.idSucursal = @0 ").
                        Append("LEFT OUTER JOIN configuracionFactDet CFD ON CF.idConFact = CFD.idConFact ").
                        Append("WHERE CF.ST = 1 AND CF.idEmpresa = @idEmpresa AND CF.idTipoComp = @1 AND idCFDProcedencia = 1 AND objDesc NOT LIKE 'nuevoLbl%' ");
                }

                DataTable dtConfigFact = dal.QueryDT("DS_FE", sbConfigFact.ToString(), sbConfigFactParms.ToString(), hc);

                // Creamos el Objeto Documento
                Document document = new Document(PageSize.LETTER, 25, 25, 25, 25);
                document.AddAuthor("Facturaxion");
                document.AddCreator("r3Take");
                document.AddCreationDate();
                //FileStream fs = new FileStream(pathPdf, FileMode.Create);
                //FileStream fs = new FileStream(pathPdf, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
                PdfWriter writer = PdfWriter.GetInstance(document, fs);
                writer.SetPdfVersion(PdfWriter.PDF_VERSION_1_7);

                Chunk cSaltoLinea = new Chunk("\n");
                Chunk cLineaSpace = new Chunk(cSaltoLinea + "________________________________________________________________________________________________________________________________________________________________________", new Font(Font.HELVETICA, 6, Font.BOLD));
                Chunk cLineaDiv = new Chunk(cSaltoLinea + "________________________________________________________________________________________________________________________________________________________________________" + cSaltoLinea, new Font(Font.HELVETICA, 6, Font.BOLD));
                Chunk cDataSpacer = new Chunk("      |      ", new Font(Font.HELVETICA, 6, Font.BOLD));

                BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                document.Open();
                PdfContentByte cb = writer.DirectContent;
                cb.BeginText();

                // Almacenamos en orden los objetos del Electronic Document para posteriormente añadidos al documento

                #region "Armamos las etiquetas que tienen posiciones absolutas para ser insertadas en el documento"

                Hashtable htDatosCfdi = new Hashtable();

                // Armamos las direcciones

                #region "Dirección Emisor"

                StringBuilder sbDirEmisor1 = new StringBuilder();
                StringBuilder sbDirEmisor2 = new StringBuilder();
                StringBuilder sbDirEmisor3 = new StringBuilder();

                if (electronicDocument.Data.Emisor.Domicilio.Calle.Value.Length > 0)
                {
                    sbDirEmisor1.Append("Calle ").Append(electronicDocument.Data.Emisor.Domicilio.Calle.Value).Append(" ");
开发者ID:Bloodrider,项目名称:wsFacturizate,代码行数:67,代码来源:tecamac.cs

示例12: exportarToPdf

        /*
         * Requiere: N/A
         * Modifica: Exporta el grid de vista previa a un PDF y abre una nueva pestaña en el browser que la previsualiza. Si el usuario lo desea puede descargar el documento desde ahi.
         * Retorna: N/A.
         */
        protected void exportarToPdf()
        {
            string nombreReporte = "Reporte Doroteos.pdf";

            iTextSharp.text.Document doc = new iTextSharp.text.Document(iTextSharp.text.PageSize.LETTER);
            if (preGrid.Rows[0].Cells.Count > 4)
                doc.SetPageSize(iTextSharp.text.PageSize.LETTER.Rotate());

            var output = new System.IO.FileStream(Server.MapPath(nombreReporte), System.IO.FileMode.Create);
            var writer = PdfWriter.GetInstance(doc, output);
            doc.Open();

            iTextSharp.text.Rectangle page = doc.PageSize;
            PdfPTable head = new PdfPTable(1);
            head.TotalWidth = page.Width;
            Phrase phrase = new Phrase("Reporte generado el: " + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + " GMT", new iTextSharp.text.Font(iTextSharp.text.Font.COURIER, 8));
            PdfPCell c = new PdfPCell(phrase);
            c.Border = iTextSharp.text.Rectangle.NO_BORDER;
            c.VerticalAlignment = Element.ALIGN_TOP;
            c.HorizontalAlignment = Element.ALIGN_CENTER;
            head.AddCell(c);
            doc.Add(head);
            doc.AddCreationDate();
            iTextSharp.text.Font boldFont = new iTextSharp.text.Font(iTextSharp.text.Font.TIMES_ROMAN, 24, iTextSharp.text.Font.BOLD);
            iTextSharp.text.Font boldFontHeader = new iTextSharp.text.Font(iTextSharp.text.Font.TIMES_ROMAN, 14, iTextSharp.text.Font.BOLD);
            doc.Add(new iTextSharp.text.Paragraph("Reporte de proyectos", boldFont));
            doc.Add(new iTextSharp.text.Paragraph(" ", boldFont));

            BaseFont fieldFontRoman = BaseFont.CreateFont(@"C:\Windows\Fonts\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            iTextSharp.text.Font normalCell = new iTextSharp.text.Font(fieldFontRoman, 11, iTextSharp.text.Font.NORMAL);
            iTextSharp.text.Font ff = new iTextSharp.text.Font(fieldFontRoman, 13, iTextSharp.text.Font.BOLD);

            /*Se agregan datos de proyecto, en caso de ser seleccionado*/

            PdfPTable table = new PdfPTable(preGrid.Rows[0].Cells.Count);

            for (int i = 0; i < preGrid.Rows[0].Cells.Count; i++)
            {
                Phrase p = new Phrase(HttpUtility.HtmlDecode(preGrid.HeaderRow.Cells[i].Text), ff);
                PdfPCell cell = new PdfPCell(p);
                float level = 0.80F;
                GrayColor gray = new GrayColor(level);
                cell.BackgroundColor = gray;

                bool tiene = cell.HasMinimumHeight();
                //Phrase p = new Phrase(quitarTildes(preGrid.HeaderRow.Cells[i].Text), ff);
                table.AddCell(cell);
            }

            foreach (GridViewRow row in preGrid.Rows)
            {
                for (int i = 0; i < preGrid.Rows[0].Cells.Count; i++)
                {

                    Phrase p = new Phrase(HttpUtility.HtmlDecode(row.Cells[i].Text), normalCell);
                    //Phrase p = new Phrase(quitarTildes(row.Cells[i].Text), normalCell);
                    PdfPCell cell = new PdfPCell(p);
                    cell.PaddingBottom = 7.0F;
                    cell.PaddingTop = 7.0F;
                    table.AddCell(cell);
                }

            }

            doc.Add(table);

            //Se cierra documento
            doc.Close();

            Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('" + nombreReporte + "','_newtab');", true);
        }
开发者ID:LosDoris,项目名称:Proyecto_Sistema_Pruebas,代码行数:76,代码来源:InterfazReporte.aspx.cs

示例13: Ausencia

        public Ausencia(AufenPortalReportesDataContext db, EMPRESA empresa, vw_Ubicacione departamento, DateTime FechaDesde, DateTime FechaHasta, string path, string rut)
        {
            //Nombre del archivo y ubiación en el árbol de carpetas
            NombreArchivo = String.Format("{0}/{1}/PersonalAusente.pdf", empresa.Descripcion, departamento.Descripcion);
            // Vamos a buscar los datos que nos permitirtán armar elreporte
            IEnumerable<sp_LibroInasistenciaResult> resultado = 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).OrderBy(x => x.Fecha).ToList();
            IEnumerable<LibroInasistenciaDTO> inasistencias =
                Mapper.Map<IEnumerable<sp_LibroInasistenciaResult>, IEnumerable<LibroInasistenciaDTO>>(resultado);
            if (inasistencias.Any())
            {
                Configuracion();
                Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 50, 35);
                using (var ms = new MemoryStream())
                {
                    PdfWriter pdfWriter = PdfWriter.GetInstance(doc, ms);
                    pdfWriter.PageEvent = new Header(empresa, path);
                    doc.Open();
                    foreach (var reporte in inasistencias.Where(x=>x.Rut!=null).GroupBy(x => new { x.Rut, x.IdDepartamento, x.IdEmpresa }).Take(3))
                    {
                        doc.AddAuthor("Aufen");
                        doc.AddCreationDate();
                        doc.AddCreator("Aufen");
                        doc.AddTitle("Informe de Personal Ausente (sin marcas)");

                        Paragraph parrafo = new Paragraph();

                        parrafo.Add(new Paragraph("Informe de Personal Ausente (sin marcas)", Titulo) { Alignment = Element.ALIGN_CENTER });
                        parrafo.Add(new Paragraph(String.Format("Período: {0} a {1}", FechaDesde.ToShortDateString(), FechaHasta.ToShortDateString()), Normal) { Alignment = Element.ALIGN_CENTER });
                        parrafo.Add(new Paragraph("Centro de Costos:", Normal));

                        doc.Add(parrafo);
                        doc.Add(new Phrase());

                        PdfPTable tabla = new PdfPTable(new float[] {2, 2, 2, 2, 1, 1, 4 });
                        // Encabezado
                        tabla.AddCell(new PdfPCell(new Phrase("Empleado", Normal)) { Colspan = 4});
                        tabla.AddCell(new PdfPCell(new Phrase("Horario", Normal)) { Colspan = 2 });
                        tabla.AddCell(new PdfPCell(new Phrase("Autorizaciones", Normal)));

                        // 2 encabezado
                        tabla.AddCell(new PdfPCell(new Phrase("Fecha", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Rut", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Apellidos", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Nombres", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Ing.", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Sal.", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Autorizaciones", Chico)));

                        var empleado = db.vw_Empleados.FirstOrDefault(x => x.IdEmpresa == empresa.Codigo &&
                            x.IdUbicacion == reporte.Key.IdDepartamento &&  x.Codigo == reporte.Key.Rut);
                        foreach(var ausencia in reporte)
                        {
                            //Fecha
                            tabla.AddCell(new PdfPCell(new Phrase(ausencia.Fecha.HasValue ? ausencia.Fecha.Value.ToString("ddd dd/MM") : String.Empty, Chico)));
                            //Código
                            tabla.AddCell(new PdfPCell(new Phrase(empleado.RutAufen, Chico)));
                            //Apellidos
                            tabla.AddCell(new PdfPCell(new Phrase((ausencia.Apellidos ?? string.Empty).Trim(), Chico)));
                            //Nombres
                            tabla.AddCell(new PdfPCell(new Phrase((ausencia.Nombres ?? string.Empty).Trim(), Chico)));
                            //Ing.
                            tabla.AddCell(new PdfPCell(new Phrase(ausencia.EntradaTeorica.HasValue ? ausencia.EntradaTeorica.Value.ToString("HH:mm") : String.Empty, Chico)));
                            //Sal.
                            tabla.AddCell(new PdfPCell(new Phrase(ausencia.SalidaTeorica.HasValue ? ausencia.SalidaTeorica.Value.ToString("HH:mm") : String.Empty, Chico)));
                            //Autorizaciones
                            tabla.AddCell(new PdfPCell(new Phrase(ausencia.Observacion, Chico)));
                        }
                        doc.Add(tabla);
                        doc.NewPage();
                    }
                    doc.Close();
                    _Archivo = ms.ToArray();
                }
            }
        }
开发者ID:LazyAbstract,项目名称:AReportes,代码行数:80,代码来源:Ausencia.cs

示例14: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            //creamos el documento
            //...ahora configuramos para que el tamaño de hoja sea A4
            Document document = new Document(iTextSharp.text.PageSize.A4);
            //document.PageSize.BackgroundColor = new iTextSharp.text.BaseColor(255, 255, 255);
            document.PageSize.Rotate();

            //...definimos el autor del documento.
            document.AddAuthor("Arbis Percy Reyes Paredes");

            //...el creador, que será el mismo eh!
            document.AddCreator("Arbis Percy Reyes Paredes");

            //hacemos que se inserte la fecha de creación para el documento
            document.AddCreationDate();
            //...título

            document.AddTitle("Generación de un pdf con itextSharp");
            //... el asunto

            document.AddSubject("Este es un paso muy important");
            //... palabras claves

            document.AddKeywords("pdf, PdfWriter; Documento; iTextSharp");

            //creamos un instancia del objeto escritor de documento
            PdfWriter writer = PdfWriter.GetInstance(document, new System.IO.FileStream
            ("Code.pdf", System.IO.FileMode.Create));

            //encriptamos el pdf, dándole como clave de usuario "key" y la clave del dueño será "owner"
            //si quitas los comentarios (en writer.SetEncryption...), entonces el documento generado
            //no mostrarà tanto la información de autor, titulo, fecha de creacion...
            //que habiamos establecio más arriba. y sólo podrás abrirlo con una clave

            //writer.SetEncryption(PdfWriter.STRENGTH40BITS,"key","owner", PdfWriter.CenterWindow);

            //definimos la manera de inicialización de abierto del documento.
            //esto, hará que veamos al inicio, todas la páginas del documento
            //en la parte izquierda
            writer.ViewerPreferences = PdfWriter.PageModeUseThumbs;

            //con esto conseguiremos que el documento sea presentada de dos en dos
            writer.ViewerPreferences = PdfWriter.PageLayoutTwoColumnLeft;

            //con esto podemos oculta las barras de herramienta y de menú respectivamente.
            //(quite las dos barras de comentario de la siguiente línea para ver los efectos)
            //PdfWriter.HideToolbar | PdfWriter.HideMenubar

            //abrimos el documento para agregarle contenido
            document.Open();

            //este stream es para jalar el código
            string TemPath = Application.StartupPath.ToString();
            TemPath = TemPath.Substring(0, TemPath.Length - 10);
            string pathFileForm1cs = TemPath + @"\Form1.cs";
            System.IO.StreamReader reader = new System.IO.StreamReader(pathFileForm1cs);

            //leemos primera línea
            string linea = reader.ReadLine();

            //creamos la fuente
            iTextSharp.text.Font myfont = new iTextSharp.text.Font(
            FontFactory.GetFont(FontFactory.COURIER, 10, iTextSharp.text.Font.ITALIC));

            //creamos un objeto párrafo, donde insertamos cada una de las líneas que
            //se vaya leyendo mediante el reader
            Paragraph myParagraph = new Paragraph("Código fuente en Visual C# \n\n", myfont);

            do
            {
                //leyendo linea de texto
                linea = reader.ReadLine();
                //concatenando cada parrafo que estará formado por una línea
                myParagraph.Add(new Paragraph(linea, myfont));
            } while (linea != null);  //mientras no llegue al final de documento, sigue leyendo

            //agregar todo el paquete de texto
            document.Add(myParagraph);

            //esto es importante, pues si no cerramos el document entonces no se creara el pdf.
            document.Close();

            //esto es para abrir el documento y verlo inmediatamente después de su creación
            System.Diagnostics.Process.Start("C:\\Program Files (x86)\\Foxit PhantomPDF\\FoxitPhantomPDF.exe", "Code.pdf");
        }
开发者ID:ccastilvania,项目名称:Programacion-en-c-,代码行数:86,代码来源:Form1.cs

示例15: LibroAtrasos

        public LibroAtrasos(AufenPortalReportesDataContext db, EMPRESA empresa, vw_Ubicacione departamento, DateTime FechaDesde, DateTime FechaHasta, string path, string rut)
        {
            //Nombre del archivo y ubiación en el árbol de carpetas
            NombreArchivo = String.Format("{0}/{1}/LibroAtrasos.pdf", empresa.Descripcion, departamento.Descripcion);
            // Vamos a buscar los datos que nos permitirtán armar elreporte
            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> libroAtrasos = Mapper.Map<IEnumerable<sp_LibroAsistenciaResult>,
                IEnumerable<LibroAsistenciaDTO>>(resultadoLibroAtrasos)
            .Where(x =>x.Entrada.HasValue && x.Salida.HasValue && x.SalidaTeorica.HasValue && x.EntradaTeorica.HasValue &&
                x.Entrada > x.EntradaTeorica);
            // Comenzaremos a crear el reporte
            if (libroAtrasos.Any())
            {
                Configuracion();
                Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 50, 35);
                using (var ms = new MemoryStream())
                {
                    PdfWriter pdfWriter = PdfWriter.GetInstance(doc, ms);
                    pdfWriter.PageEvent = new Header(empresa, path);
                    doc.Open();
                    foreach (var reporte in libroAtrasos.GroupBy(x => new { x.Rut, x.IdDepartamento, x.IdEmpresa }))
                    {
                        var empleado = db.vw_Empleados.FirstOrDefault(x => x.IdEmpresa == empresa.Codigo &&
                            x.IdUbicacion == reporte.Key.IdDepartamento &&
                                  x.Codigo == reporte.Key.Rut);
                        if (empleado == null)
                        {
                            empleado = new vw_Empleado();
                        }

                        doc.AddAuthor("Aufen");
                        doc.AddCreationDate();
                        doc.AddCreator("Aufen");
                        doc.AddTitle("Libro de Atrasos");
                        // Texto
                        Paragraph parrafo = new Paragraph();
                        parrafo.Add(new Paragraph(
                            String.Format("Departamento: {1}, Fecha de Reporte: {0}",
                            DateTime.Now.ToShortDateString(),
                            departamento.SucursalPlanta), Normal) { Alignment = Element.ALIGN_CENTER });
                        parrafo.Add(new Paragraph("Informe de Atrasos por Área", Titulo) { Alignment = Element.ALIGN_CENTER });
                        doc.Add(parrafo);
                        doc.Add(new Phrase());
                        doc.Add(new Phrase());

                        PdfPTable informacionPersonal = new PdfPTable(new float[] { 1,5});
                        informacionPersonal.AddCell(new PdfPCell(new Phrase("Rut:", Normal)));
                        informacionPersonal.AddCell(new PdfPCell(new Phrase(empleado.RutAufen, NormalNegrita)));
                        informacionPersonal.AddCell(new PdfPCell(new Phrase("Nombre:", Normal)));
                        informacionPersonal.AddCell(new PdfPCell(new Phrase(empleado.NombreCompleto, NormalNegrita)));
                        informacionPersonal.AddCell(new PdfPCell(new Phrase("Centro de Costos:", Normal)));
                        informacionPersonal.AddCell(new PdfPCell(new Phrase(String.Empty, NormalNegrita)));
                        doc.Add(new Phrase());

                        doc.Add(informacionPersonal);
                        // tabla
                        PdfPTable tabla = new PdfPTable(new float[] {2, 2, 2, 2, 2, 2, 2, 4 });
                        // Primera lìnea cabecera
                        tabla.AddCell(new PdfPCell(new Phrase("Fecha", Chico)) { Rowspan = 2 });
                        //tabla.AddCell(new PdfPCell(new Phrase("Empleado", Chico)) { Colspan = 3 });
                        tabla.AddCell(new PdfPCell(new Phrase("Horario", Chico)) { Colspan = 2 });
                        tabla.AddCell(new PdfPCell(new Phrase("Marcas", Chico)) { Colspan = 2 });
                        tabla.AddCell(new PdfPCell(new Phrase("Horas Trabajadas", Chico)) { Colspan = 2 });
                        tabla.AddCell(new PdfPCell(new Phrase("Autorizaciones", Chico)));
                        // Segunda lìnea cabecera
                        //tabla.AddCell(new PdfPCell(new Phrase("Rut", Chico)));
                        //tabla.AddCell(new PdfPCell(new Phrase("Apellidos", Chico)));
                        //tabla.AddCell(new PdfPCell(new Phrase("Nombres", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Ing.", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Sal.", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Ing.", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Sal.", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Atrasos", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("H.T.N.", Chico)));
                        tabla.AddCell(new PdfPCell(new Phrase("Permisos", Chico)));

                        foreach (var atraso in reporte)
                        {
                            TimeSpan tiempoAtraso =
                                (atraso.Salida.HasValue && atraso.Entrada.HasValue ? atraso.Salida.Value.Subtract(atraso.Entrada.Value) : new TimeSpan(0)) -
                                (atraso.SalidaTeorica.HasValue && atraso.EntradaTeorica.HasValue ? atraso.SalidaTeorica.Value.Subtract(atraso.EntradaTeorica.Value) : new TimeSpan(0));
                            TimeSpan tiempoNormal = atraso.SalidaTeorica.HasValue && atraso.EntradaTeorica.HasValue ? atraso.SalidaTeorica.Value.Subtract(atraso.EntradaTeorica.Value) : new TimeSpan(0);
                            tabla.AddCell(new PdfPCell(new Phrase(atraso.Fecha.Value.ToString("ddd dd/MM"), Chico)) { HorizontalAlignment = Element.ALIGN_LEFT });
                            //tabla.AddCell(new PdfPCell(new Phrase(atraso.Rut.ToStringConGuion(), Chico)));
                            //tabla.AddCell(new PdfPCell(new Phrase(atraso.Apellidos, Chico)));
                            //tabla.AddCell(new PdfPCell(new Phrase(atraso.Nombres, Chico)));
                            tabla.AddCell(new PdfPCell(new Phrase(atraso.Entrada.HasValue ? atraso.Entrada.Value.ToString("HH:mm") : String.Empty, Chico)));
                            tabla.AddCell(new PdfPCell(new Phrase(atraso.Salida.HasValue ? atraso.Salida.Value.ToString("HH:mm") : String.Empty, Chico)));
                            tabla.AddCell(new PdfPCell(new Phrase(atraso.EntradaTeorica.HasValue ? atraso.EntradaTeorica.Value.ToString("HH:mm") : String.Empty, Chico)));
                            tabla.AddCell(new PdfPCell(new Phrase(atraso.SalidaTeorica.HasValue ? atraso.SalidaTeorica.Value.ToString("HH:mm") : String.Empty, Chico)));
                            tabla.AddCell(new PdfPCell(new Phrase(atraso.printAtraso, Chico)));
                            tabla.AddCell(new PdfPCell(new Phrase("", Chico)));
                            tabla.AddCell(new PdfPCell(new Phrase(atraso.Observacion, Chico)));
                        }
//.........这里部分代码省略.........
开发者ID:LazyAbstract,项目名称:AReportes,代码行数:101,代码来源:LibroAtrasos.cs


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