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


C# HTMLWorker.EndDocument方法代码示例

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


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

示例1: GetPDF

        public byte[] GetPDF(string pHTML)
        {
            byte[] bPDF = null;

            MemoryStream ms = new MemoryStream();
            TextReader txtReader = new StringReader(pHTML);

            // 1: create object of a itextsharp document class
            Document doc = new Document(PageSize.A4, 10, 10, 10, 5); //era tudo 25

            // 2: we create a itextsharp pdfwriter that listens to the document and directs a XML-stream to a file
            PdfWriter oPdfWriter = PdfWriter.GetInstance(doc, ms);

            // 3: we create a worker parse the document
            HTMLWorker htmlWorker = new HTMLWorker(doc);

            // 4: we open document and start the worker on the document
            doc.Open();
            htmlWorker.StartDocument();

            // 5: parse the html into the document
            htmlWorker.Parse(txtReader);

            // 6: close the document and the worker
            htmlWorker.EndDocument();
            htmlWorker.Close();
            doc.Close();

            bPDF = ms.ToArray();

            return bPDF;
        }
开发者ID:andresombra,项目名称:ged,代码行数:32,代码来源:GeraPDF.cs

示例2: createPDF

        private MemoryStream createPDF(string html)
        {
            MemoryStream msOutput = new MemoryStream();
            TextReader reader = new StringReader(html);

            // step 1: creation of a document-object
            Document document = new Document(PageSize.A4, 30, 30, 30, 30);

            // step 2:
            // we create a writer that listens to the document
            // and directs a XML-stream to a file
            PdfWriter writer = PdfWriter.GetInstance(document, msOutput);

            // step 3: we create a worker parse the document
            HTMLWorker worker = new HTMLWorker(document);

            // step 4: we open document and start the worker on the document
            document.Open();
            worker.StartDocument();

            // step 5: parse the html into the document
            worker.Parse(reader);

            // step 6: close the document and the worker
            worker.EndDocument();
            worker.Close();
            document.Close();

            return msOutput;
        }
开发者ID:Nsobi,项目名称:PoliceReports,代码行数:30,代码来源:PDFUtility.cs

示例3: RenderHtmlToPdfStream

        public static MemoryStream RenderHtmlToPdfStream(string html)
        {
            var memoryStream = new MemoryStream();

            var reader = new StringReader(html);

            using (var document = new Document(PageSize.A4, 30, 30, 30, 30))
            {
                using (var worker = new HTMLWorker(document))
                {
                    using (var writer = PdfWriter.GetInstance(document, memoryStream))
                    {
                        writer.CloseStream = false;

                        document.Open();
                        worker.StartDocument();

                        worker.Parse(reader);

                        worker.EndDocument();
                        worker.Close();
                        document.Close();
                    }
                }
            }
            memoryStream.Seek(0, 0);
            return memoryStream;
        }
开发者ID:n-hogan,项目名称:master,代码行数:28,代码来源:PdfRenderer.cs

示例4: RenderFromHtml

        public byte[] RenderFromHtml(string html)
        {
            var output = new MemoryStream ();
            using (var reader = new StringReader (html)) {
                var document = new Document ();
                var worker = new HTMLWorker (document);

                document.Open ();
                worker.StartDocument ();
                worker.Parse (reader);

                worker.EndDocument ();
                worker.Close ();
                document.Close ();

                return output.ToArray ();
            }
        }
开发者ID:AlexCuse,项目名称:RazorReport,代码行数:18,代码来源:PdfRenderer.cs

示例5: createPDF

        private MemoryStream createPDF()
        {

            string html = BdyTextBox.Text;

            MemoryStream msOutput = new MemoryStream();

            TextReader reader = new StringReader(html);

            Document document = new Document(PageSize.A4, 30, 30, 30, 30);

            PdfWriter writer = PdfWriter.GetInstance(document, msOutput);

            HTMLWorker worker = new HTMLWorker(document);

            document.Open();

            worker.StartDocument();

            worker.Parse(reader);

            worker.EndDocument();

            worker.Close();

            document.Close();
           


            return msOutput;
        }
开发者ID:karayakar,项目名称:SharePoint,代码行数:31,代码来源:PrintView.aspx.cs

示例6: RelatorioPDF


//.........这里部分代码省略.........
            }
            if (_flt.Conta != "")
            {
                doc.Add(new Paginacao().Paragrafo("Conta: " + _flt.Conta + "\n", 10f));
            }
            if (_flt.Credor != "")
            {
                doc.Add(new Paginacao().Paragrafo("Credor: " + _flt.Credor + "\n", 10f));
            }
            if (_flt.DocCaixa != "")
            {
                doc.Add(new Paginacao().Paragrafo("Doc. Caixa: " + _flt.DocCaixa + "\n", 10f));
            }
            if (_flt.NotaEmp != "")
            {
                doc.Add(new Paginacao().Paragrafo("Nota Empenho: " + _flt.NotaEmp + "\n", 10f));
            }
            //if (_flt.Tipo != 0)
            //{
                doc.Add(new Paginacao().Paragrafo("Documentos: " + new Retorno().TipoDocumento(_flt.Tipo) + "\n", 10f));
            //}
            doc.Add(new Paginacao().Paragrafo("___________________________________________________________________________________________ \n", 10f));

            PdfPTable tbl = new PdfPTable(7); //3 é quantidade de colunas
            float[] anchoDeColumnas = new float[] { 50f, 50f, 200f, 50f, 40f, 45f, 50f };
            tbl.SetWidths(anchoDeColumnas);
            tbl.DefaultCell.Border = Rectangle.NO_BORDER;

            Filtro flt = (Filtro)Session["Filtro"];
            if (flt == null) throw new Exception("Nenhum registro encontrado, tente novamente...");
            if (flt != null)
            {
                var lista = new Processo().ListaAnoMes(flt.DataRefDoc, flt.Tipo, flt.DocCaixa, flt.NotaEmp, flt.DataInicio, flt.DataFim, flt.Credor, flt.Conta, flt.CodigoUnidadeGestora);

                tbl.AddCell(new Paginacao().ColCabecalho("Doc.caixa"));
                tbl.AddCell(new Paginacao().ColCabecalho("Empenho"));
                tbl.AddCell(new Paginacao().ColCabecalho("Credor"));
                tbl.AddCell(new Paginacao().ColCabecalho("Data Pagam",Alinhar.ESQUERDA));
                tbl.AddCell(new Paginacao().ColCabecalho("Ung"));
                tbl.AddCell(new Paginacao().ColCabecalho("Valor",Alinhar.DIREITA));
                tbl.AddCell(new Paginacao().ColCabecalho("Qtd.Docs",Alinhar.DIREITA));
                int totDocs = 0;
                int reg = 0;

                var lstDocumentos = db.DOCUMENTOS.ToList();

                foreach (var itm in lista)
                {
                    string doccaixa = new Funcoes().NaoNull(itm.PRC_DOCCAIXA);
                    string notaemp = new Funcoes().NaoNull(itm.PRC_NOTAEMP);
                    string credor = new Funcoes().NaoNull(itm.PRC_CREDOR);
                    string dtpagam = new Funcoes().NaoNull(itm.PRC_DTPAGAM);
                    string undgest = new Funcoes().NaoNull(itm.PRC_UND_GEST);
                    string vrpagam = new Funcoes().NaoNullDec(itm.PRC_VRPAGAM);
                    //string totdocumento = new Documento().TotalDocumento(itm.PRC_ID).ToString();
                    string totdocumento = lstDocumentos.Where(x => x.DOC_PROC_ID == itm.PRC_ID).Count().ToString();

                    tbl.AddCell(new Paginacao().ColValor(doccaixa));
                    tbl.AddCell(new Paginacao().ColValor(notaemp));
                    tbl.AddCell(new Paginacao().ColValor(credor));
                    tbl.AddCell(new Paginacao().ColValor(dtpagam,Alinhar.ESQUERDA));
                    tbl.AddCell(new Paginacao().ColValor(undgest));
                    tbl.AddCell(new Paginacao().ColValor(vrpagam,Alinhar.DIREITA));
                    tbl.AddCell(new Paginacao().ColValor(totdocumento,Alinhar.CENTRO));

                    totDocs += int.Parse(totdocumento);
                    reg++;
                }
                doc.Add(tbl);

                doc.Add(new Paginacao().Paragrafo("___________________________________________________________________________________________ \n\n", 10f));
                doc.Add(new Paginacao().Paragrafo("Total de processos listados: " + reg.ToString() + "        Total Documentos: " + totDocs.ToString() + "\n", 10f));

                doc.NewPage();

                htmlWorker.StartDocument();

                // 5: parse the html into the document
                htmlWorker.Parse(txtReader);

                // 6: close the document and the worker
                htmlWorker.EndDocument();
                htmlWorker.Close();
                doc.Close();

                bPDF = ms.ToArray();

                Response.Clear();
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment;filename=" + "RelProcessos.pdf");
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.BinaryWrite(bPDF);
                Response.End();
            }
            else
            {
                TempData["MsgErro"] = "Sem registros para listar em relatório...";
            }
            //return RedirectToAction("Index");
        }
开发者ID:andresombra,项目名称:ged,代码行数:101,代码来源:ProcessosController.cs

示例7: ConvertHtmlToPdf

        public static void ConvertHtmlToPdf(string documentFilename, string HTMLCode, PaperSize paperSize)
        {
            Rectangle pageSize = PageSize.A4;
            switch (paperSize)
            {
            case PaperSize.A4:
                pageSize = PageSize.A4;
                break;
            case PaperSize.A4_LANDSCAPE:
                pageSize = PageSize.A4_LANDSCAPE;
                break;
            case PaperSize.LETTER:
                pageSize = PageSize.LETTER;
                break;
            case PaperSize.LETTER_LANDSCAPE:
                pageSize = PageSize.LETTER_LANDSCAPE;
                break;
            }

            HttpContext context = HttpContext.Current;

            //Render PlaceHolder to temporary stream
            StringWriter stringWrite = new StringWriter();
            HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

            string postContent = getImage(HTMLCode);

            StringReader reader = new StringReader(postContent);

            //Create PDF document
            Document doc = new Document(pageSize);
            HTMLWorker parser = new HTMLWorker(doc);
            PdfWriter.GetInstance(doc, new FileStream(documentFilename, FileMode.Create));
            doc.Open();
            try
            {
                parser.Parse(reader);
                parser.EndDocument();
            }
            catch (Exception ex)
            {
                Logger.Instance.Write(LogLevel.Error, ex, "[Util.ConvertHtmlToPdf]");
                // Display parser errors in PDF.
                Paragraph paragraph = new Paragraph("Error!" + ex.Message);
                Chunk text = paragraph.Chunks[0] as Chunk;
                if (text != null)
                    text.Font.Color = BaseColor.RED;
                doc.Add(paragraph);
            }
            finally
            {
                parser.Close();
                doc.Close();
            }
        }
开发者ID:nageshverma2003,项目名称:TrackProtectSource,代码行数:55,代码来源:Util.cs

示例8: RelatorioLista


//.........这里部分代码省略.........
            }
            if (_flt.Tipo != 0)
            {
                doc.Add(new Paginacao().Paragrafo("Documentos: " + new Retorno().TipoDocumento(_flt.Tipo) + "\n", 10f));
            }

            doc.Add(new Paginacao().Paragrafo("___________________________________________________________________________________________ \n", 10f));

            PdfPTable tbl = new PdfPTable(6); //3 é quantidade de colunas
            float[] anchoDeColumnas = new float[] { 50f, 60f, 40f, 160f, 55f, 45f };
            tbl.SetWidths(anchoDeColumnas);
            tbl.DefaultCell.Border = Rectangle.NO_BORDER;

            /*tbl.AddCell("TESTE 1");
            tbl.AddCell("TESTE 2");
            tbl.AddCell("Grupo Teste da Silva Rodrigues LDTA");
            tbl.AddCell("TESTE 4");
            tbl.AddCell("TESTE 5");
            tbl.AddCell("TESTE 6");*/

            Filtro flt = (Filtro)Session["Filtro"];
            if (flt != null)
            {
               var lista = new DAO.Licitacao().ListaLicitacaoFiltro(flt);

               tbl.AddCell(new Paginacao().ColCabecalho("Num.Proc."));
               tbl.AddCell(new Paginacao().ColCabecalho("Modalidade"));
               tbl.AddCell(new Paginacao().ColCabecalho("Dt.Real"));
               tbl.AddCell(new Paginacao().ColCabecalho("Descrição do Objeto"));
               tbl.AddCell(new Paginacao().ColCabecalho("Unid.Gestora"));
               tbl.AddCell(new Paginacao().ColCabecalho("Quant.Doc"));
               int totDocs = 0;
               int reg = 0;
               foreach (var lst in lista)
               {
                   PdfPCell cell1 = new PdfPCell(new Phrase(lst.NUMPROC.ToString(), new Font(Font.FontFamily.HELVETICA, 8f, Font.NORMAL)));
                   cell1.Border = 0;
                   tbl.AddCell(cell1);

                   PdfPCell cell2 = new PdfPCell(new Phrase(lst.MOLMODALIDADE.ToString(), new Font(Font.FontFamily.HELVETICA, 8f, Font.NORMAL)));
                   cell2.Border = 0;
                   tbl.AddCell(cell2);

                   PdfPCell cell3 = new PdfPCell(new Phrase(lst.DTREAL.ToString(), new Font(Font.FontFamily.HELVETICA, 8f, Font.NORMAL)));
                   cell3.Border = 0;
                   tbl.AddCell(cell3);

                   PdfPCell cell4 = new PdfPCell(new Phrase(lst.DESCOBJ.ToString(), new Font(Font.FontFamily.HELVETICA, 8f, Font.NORMAL)));
                   cell4.Border = 0;
                   tbl.AddCell(cell4);

                   string ungs = new Licitacao().RetornaUnidadeGestora(lst.ID).ToString();
                   PdfPCell cell5 = new PdfPCell(new Phrase(ungs, new Font(Font.FontFamily.HELVETICA, 8f, Font.NORMAL)));
                   cell5.Border = 0;
                   tbl.AddCell(cell5);

                   string qtdimg = lst.QTDIMG.ToString();
                   PdfPCell cell6 = new PdfPCell(new Phrase(qtdimg, new Font(Font.FontFamily.HELVETICA, 8f, Font.NORMAL)));
                   cell6.Border = 0;
                   tbl.AddCell(cell6);

                   totDocs += int.Parse(qtdimg);
                   reg++;
                   //PdfPCell cell = new PdfPCell(new Phrase("TESTE 7", new Font(Font.FontFamily.HELVETICA, 8f, Font.NORMAL, BaseColor.BLACK)));
                   //cell.Border = 0;
                   //tbl.AddCell(cell);
               }
               doc.Add(tbl);

               doc.Add(new Paginacao().Paragrafo("\n\n", 10f));
               doc.Add(new Paginacao().Paragrafo("___________________________________________________________________________________________ \n\n", 10f));
               doc.Add(new Paginacao().Paragrafo("Total de processos listados: " + reg.ToString() + "        Total Documentos: " + totDocs.ToString() + "\n", 10f));

               doc.NewPage();

               htmlWorker.StartDocument();

               // 5: parse the html into the document
               htmlWorker.Parse(txtReader);

               // 6: close the document and the worker
               htmlWorker.EndDocument();
               htmlWorker.Close();
               doc.Close();

               bPDF = ms.ToArray();

               Response.Clear();
               Response.ContentType = "application/pdf";
               Response.AddHeader("content-disposition", "attachment;filename=" + "RelLicitacao.pdf");
               Response.Cache.SetCacheability(HttpCacheability.NoCache);
               Response.BinaryWrite(bPDF);
               Response.End();
            }
            else
            {
                TempData["MsgErro"] = "Sem registros para listar em relatório...";
            }
            //return RedirectToAction("Index");
        }
开发者ID:andresombra,项目名称:ged,代码行数:101,代码来源:LicitacaoController.cs


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