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


C# text.Paragraph类代码示例

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


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

示例1: Write

        public void Write(string outputPath, FlowDocument doc)
        {
            Document pdfDoc = new Document(PageSize.A4, 50, 50, 50, 50);
            Font textFont = new Font(baseFont, DEFAULT_FONTSIZE, Font.NORMAL, BaseColor.BLACK);
            Font headingFont = new Font(baseFont, DEFAULT_HEADINGSIZE, Font.BOLD, BaseColor.BLACK);
            using (FileStream stream = new FileStream(outputPath, FileMode.Create))
            {
                PdfWriter writer = PdfWriter.GetInstance(pdfDoc, stream);
                pdfDoc.Open();
                foreach (Block i in doc.Blocks) {
                    if (i is System.Windows.Documents.Paragraph)
                    {
                        TextRange range = new TextRange(i.ContentStart, i.ContentEnd);
                        Console.WriteLine(i.Tag);
                        switch (i.Tag as string)
                        {
                            case "Paragraph": iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(range.Text, textFont);
                                par.Alignment = Element.ALIGN_JUSTIFIED;
                                              pdfDoc.Add(par);
                                              break;
                            case "Heading": iTextSharp.text.Paragraph head = new iTextSharp.text.Paragraph(range.Text, headingFont);
                                              head.Alignment = Element.ALIGN_CENTER;
                                              head.SpacingAfter = 10;
                                              pdfDoc.Add(head);
                                              break;
                            default:          iTextSharp.text.Paragraph def = new iTextSharp.text.Paragraph(range.Text, textFont);
                                              def.Alignment = Element.ALIGN_JUSTIFIED;
                                              pdfDoc.Add(def);
                                              break;

                        }
                    }
                    else if (i is System.Windows.Documents.List)
                    {
                        iTextSharp.text.List list = new iTextSharp.text.List(iTextSharp.text.List.UNORDERED, 10f);
                        list.SetListSymbol("\u2022");
                        list.IndentationLeft = 15f;
                        foreach (var li in (i as System.Windows.Documents.List).ListItems)
                        {
                            iTextSharp.text.ListItem listitem = new iTextSharp.text.ListItem();
                            TextRange range = new TextRange(li.Blocks.ElementAt(0).ContentStart, li.Blocks.ElementAt(0).ContentEnd);
                            string text = range.Text.Substring(1);
                            iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(text, textFont);
                            listitem.SpacingAfter = 10;
                            listitem.Add(par);
                            list.Add(listitem);
                        }
                        pdfDoc.Add(list);
                    }

               }
                if (pdfDoc.PageNumber == 0)
                {
                    iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(" ");
                    par.Alignment = Element.ALIGN_JUSTIFIED;
                    pdfDoc.Add(par);
                }
               pdfDoc.Close();
            }
        }
开发者ID:drdaemos,项目名称:ODTCONVERTvs10,代码行数:60,代码来源:PDFWriter.cs

示例2: GetParagraph

 /// <summary>
 /// 获取段落
 /// </summary>
 /// <returns>返回格式化后的段落对象</returns>
 public static Paragraph GetParagraph()
 {
     Paragraph par = new Paragraph();
     par.SpacingBefore = 20;
     par.IndentationLeft = 65;
     return par;
 }
开发者ID:dewade2003,项目名称:DSJL,代码行数:11,代码来源:PDFHelper.cs

示例3: Assemble

        private void Assemble()
        {
            //headers
            document.Add(makeHeader("DISCUSSION SUPPORT SYSTEM"));
            document.Add(makeHeader("Discussion report"));

            InsertLine();

            //subject
            document.Add(makeHeader(discussion.Subject, true));

            InsertLine();

            //background
            Paragraph p = new Paragraph();
            ///p.Add(TextRefsAggregater.PlainifyRichText(discussion.Background));
            p.Add(new Chunk("\n"));
            document.Add(p);

            InsertLine();

            //sources
            backgroundSources();
            document.NewPage();

            //agreement blocks
            List<ArgPoint> agreed = new List<ArgPoint>();
            List<ArgPoint> disagreed = new List<ArgPoint>();
            List<ArgPoint> unsolved = new List<ArgPoint>();
            addBlockOfAgreement("Agreed", agreed);
            addBlockOfAgreement("Disagreed", disagreed);
            addBlockOfAgreement("Unsolved", unsolved);
        }
开发者ID:gdlprj,项目名称:duscusys,代码行数:33,代码来源:ReportGenerator.cs

示例4: Create

        public static void Create(string message)
        {
            // 1. Create file
            FileStream fileStream = new FileStream(FileName, FileMode.Create, FileAccess.Write, FileShare.None);

            // 2. Create iTextSharp.text.Document object
            Document document = new Document();

            // 3. Create a iTextSharp.text.pdf.PdfWriter object. It helps to write the Document to the FileStream
            PdfWriter pdfWriter = PdfWriter.GetInstance(document, fileStream);

            // 4. Open the document
            document.Open();

            PdfPTable table = CreateTable();

            // 5. Write text
            var paragraph = new Paragraph(message);
            document.Add(paragraph);

            document.Add(table);

            // 6. Document close
            document.Close();
        }
开发者ID:Astatine-Haphazard,项目名称:AstatineTeamwork,代码行数:25,代码来源:PdfReport.cs

示例5: racunButton_Click

        private void racunButton_Click(object sender, EventArgs e)
        {
            // prvo da uneseš datum kada je plaćeno, pa onda generisati račun
            // da odabere lokaciju na koju će biti snimljeno

            string putanja;
            try
            {
                SaveFileDialog save = new SaveFileDialog();
                save.Filter = "PDF files|*.pdf";
                if (save.ShowDialog() == DialogResult.OK)
                {
                    putanja = save.FileName;

                    Document doc = new Document(iTextSharp.text.PageSize.A6, 10, 10, 42, 35);
                    PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(@putanja, FileMode.Create));
                    doc.Open();
                    Paragraph pragraf = new Paragraph("\n Vlasnik: Ime i prezime \n Fiksni telefon: (033)123-456 \n Mobilni telefon: (061)123-456 \n Email: [email protected] \n Adresa: Ulica 11 \n Grad: Sarajevo \n \n \n Zakupac: Imenko Prezimenko \n Adresa iznajmljene nekretnine: Neka ulica 23 \n\n\n Iznos za placanje: 350 KM");

                    doc.Add(pragraf);
                    doc.Close();
                }
            }
            catch (Exception)
            {
                throw new ApplicationException("Greška!");
            }
        }
开发者ID:ik15151,项目名称:etf-2013-bsc-zr,代码行数:28,代码来源:NaplacivanjeForma.cs

示例6: btnButtonPDF_Click

        private void btnButtonPDF_Click(object sender, EventArgs e)
        {
        //path to save to your desktop
            sfd.Title = "Save As PDF";
            sfd.Filter = "PDF|.PDF";
            sfd.InitialDirectory = @"C:\Users\RunningEXE\Desktop";

            sfd.InitialDirectory = @"C:\Users\Anthony J. Fiori\Desktop";


        //pops up the dialog box to actually save
            if (sfd.ShowDialog() == DialogResult.OK)
            { 
            Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
            PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(sfd.FileName, FileMode.Create));
            //pushes out notification when PDF is created
            MessageBox.Show("PDF Saved to " + wri);

            MessageBox.Show("PDF Created");

            doc.Open();//Open Document to write
            //write some content
            Paragraph paragraph = new Paragraph(txtInfo.Text +" "+ "This is my firest line using paragraph. ");
            //now add the above created text using different class object to our pdf document
            doc.Add(paragraph);
            doc.Close();//close document
            }
        }
开发者ID:runningexe,项目名称:AS_Capstone,代码行数:28,代码来源:Form1.cs

示例7: End

        /* (non-Javadoc)
         * @see com.itextpdf.tool.xml.ITagProcessor#endElement(com.itextpdf.tool.xml.Tag, java.util.List, com.itextpdf.text.Document)
         */
        public override IList<IElement> End(IWorkerContext ctx, Tag tag, IList<IElement> currentContent) {
            List<IElement> l = new List<IElement>(1);
            if (currentContent.Count > 0) {
                IList<IElement> currentContentToParagraph = CurrentContentToParagraph(currentContent, true, true, tag, ctx);
                ParentTreeUtil pt = new ParentTreeUtil();
                try {
                    HtmlPipelineContext context = GetHtmlPipelineContext(ctx);
                    
                    bool oldBookmark = context.AutoBookmark();
                    if (pt.GetParentTree(tag).Contains(HTML.Tag.TD))
                        context.AutoBookmark(false);

                    if (context.AutoBookmark()) {
                        Paragraph title = new Paragraph();
                        foreach (IElement w in currentContentToParagraph) {
                                title.Add(w);
                        }

                        l.Add(new WriteH(context, tag, this, title));
                    }

                    context.AutoBookmark(oldBookmark);
                } catch (NoCustomContextException e) {
                    if (LOGGER.IsLogging(Level.ERROR)) {
                        LOGGER.Error(LocaleMessages.GetInstance().GetMessage(LocaleMessages.HEADER_BM_DISABLED), e);
                    }
                }
                l.AddRange(currentContentToParagraph);
            }
            return l;
        }
开发者ID:,项目名称:,代码行数:34,代码来源:

示例8: CompoundIdtoPDFStream

        public static MemoryStream CompoundIdtoPDFStream(string compoundId)
        {
            Document document = new Document(new Rectangle(147f, 68f));
            document.SetMargins(0f, 0f, 0f, 0f);
            // string fontsfolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Fonts);
            Font font = FontFactory.GetFont("Arial", 28, Color.BLACK);
            MemoryStream stream = new MemoryStream();

            try
            {
                PdfWriter pdfWriter = PdfWriter.GetInstance(document, stream);
                pdfWriter.CloseStream = false;
                Paragraph para = new Paragraph(compoundId, font);
                para.Alignment = Element.ALIGN_CENTER;
                document.Open();
                document.Add(para);
            }
            catch (DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            document.Close();

            stream.Flush();
            stream.Position = 0;
            return stream;
        }
开发者ID:Hazy24,项目名称:AssetManagerMvc,代码行数:32,代码来源:Util.cs

示例9: TextWithSymbolEncoding

        public virtual void TextWithSymbolEncoding() {
            BaseFont f = BaseFont.CreateFont(BaseFont.SYMBOL, BaseFont.SYMBOL, false);
            FileStream fs = new FileStream("fonts/SymbolFontTest/textWithSymbolEncoding.pdf", FileMode.Create);
            Document doc = new Document();
            PdfWriter writer = PdfWriter.GetInstance(doc, fs);
            Paragraph p;
            writer.CompressionLevel = 0;
            doc.Open();

            String origText = "ΑΒΓΗ€\u2022\u2663\u22c5";
            p = new Paragraph(new Chunk(origText, new Font(f, 16)));
            doc.Add(p);
            doc.Close();

            PdfReader reader = new PdfReader("fonts/SymbolFontTest/textWithSymbolEncoding.pdf");
            String text = PdfTextExtractor.GetTextFromPage(reader, 1, new SimpleTextExtractionStrategy());
            reader.Close();
            Assert.AreEqual(origText, text);

            CompareTool compareTool = new CompareTool();
            String errorMessage = compareTool.CompareByContent("fonts/SymbolFontTest/textWithSymbolEncoding.pdf", TEST_RESOURCES_PATH + "cmp_textWithSymbolEncoding.pdf", "fonts/SymbolFontTest/", "diff");
            if (errorMessage != null) {
                Assert.Fail(errorMessage);
            }
        }
开发者ID:newlysoft,项目名称:itextsharp,代码行数:25,代码来源:SymbolTest.cs

示例10: ParaRightBelowHeader

 public static Paragraph ParaRightBelowHeader(string content)
 {
     Paragraph msp = new Paragraph(content, FontConfig.ItalicFont);
     msp.Alignment = Element.ALIGN_CENTER;
     msp.SpacingAfter = 5;
     return msp;
 }
开发者ID:psautomationteam,项目名称:manufacturingmanager,代码行数:7,代码来源:FormatConfig.cs

示例11: ParaRightBeforeHeader

 public static Paragraph ParaRightBeforeHeader(string content)
 {
     Paragraph msp = new Paragraph(content, FontConfig.SmallItalicFont);
     msp.IndentationLeft = 380;
     msp.Alignment = Element.ALIGN_LEFT;
     return msp;
 }
开发者ID:psautomationteam,项目名称:manufacturingmanager,代码行数:7,代码来源:FormatConfig.cs

示例12: CreatePdf

        public void CreatePdf(Invoice invoice, string filePath)
        {
            PdfPTable saleTable = SaleTable(invoice);

            FileStream fileStream = new FileStream(filePath,
                                                    FileMode.Create,
                                                    FileAccess.Write,
                                                    FileShare.None);

            Document doc = new Document();
            PdfWriter.GetInstance(doc, fileStream);
            doc.Open();

            Paragraph date = new Paragraph("Date: " + invoice.Date.ToShortDateString()) {Alignment = 2};

            doc.Add(date);

            doc.Add(new Paragraph("Invoice To:"));
            doc.Add(new Paragraph(invoice.Customer));

            Paragraph separator = new Paragraph("_____________________________________________________________________________      ");
            separator.SpacingAfter = 5.5f;
            doc.Add(separator);

            doc.Add(saleTable);
            doc.Close();
        }
开发者ID:akrupnov,项目名称:inwk-jobs,代码行数:27,代码来源:PdfInvoiceWriter.cs

示例13: GetParagraph

        public static Paragraph GetParagraph(string text, Fonts type, int align = Element.ALIGN_LEFT)
        {
            Paragraph p;
            switch (type)
            {
                case Fonts.Footer:
                    p = new Paragraph(text, FooterFont);
                    break;

                case Fonts.ExtraLarge:
                    p = new Paragraph(text, ExtraLargeFont);
                    break;

                case Fonts.Large:
                    p = new Paragraph(text);
                    break;

                case Fonts.Compact:
                    p = new Paragraph(text, StandardFont);
                    p.SetLeading(0, 0.8f);
                    break;

                case Fonts.Standard:
                    p = new Paragraph(text, StandardFont);
                    break;

                default: throw new ArgumentOutOfRangeException("type");
            }

            p.Alignment = align;

            return p;
        }
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:33,代码来源:ElementFactory.cs

示例14: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            filePdf = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.InternetCache), "PDF_Temp.pdf");

            var document = new Document(PageSize.LETTER);

            // Create a new PdfWriter object, specifying the output stream
            var output = new FileStream(filePdf, FileMode.Create);
            var writer = PdfWriter.GetInstance(document, output);

            // Open the Document for writing
            document.Open();

            BaseFont bf = BaseFont.CreateFont (BaseFont.HELVETICA, BaseFont.CP1252, false);
            iTextSharp.text.Font font = new iTextSharp.text.Font (bf, 16, iTextSharp.text.Font.BOLD);
            var p = new Paragraph ("Sample text", font);

            document.Add (p);
            document.Close ();
            writer.Close ();

            //Close the Document - this saves the document contents to the output stream
            document.Close();
            writer.Close ();
        }
开发者ID:JamieMellway,项目名称:iTextSharpLGPL-Monotouch,代码行数:27,代码来源:iTextSharp_TestViewController.cs

示例15: addKundenanschrift

 public void addKundenanschrift(string text)
 {
     Paragraph p = new Paragraph(text);
     p.Leading = 20;
     p.Alignment = 2;
     pdf.Add(p);
 }
开发者ID:daniel9992000,项目名称:Backoffice,代码行数:7,代码来源:CreatePdf.cs


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