A Paragraph is a series of Chunks and/or Phrases.
A Paragraph has the same qualities of a Phrase, but also some additional layout-parameters:
  • the indentation
  • the alignment of the text
상속: Phrase, IIndentable, ISpaceable, IAccessibleElement
예제 #1
1
        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();
            }
        }
        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 ();
        }
예제 #3
0
        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;
        }
예제 #4
0
 public void addKundenanschrift(string text)
 {
     Paragraph p = new Paragraph(text);
     p.Leading = 20;
     p.Alignment = 2;
     pdf.Add(p);
 }
        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();
        }
예제 #6
0
 private void button2_Click(object sender, EventArgs e)
 {
     BaseFont bfTimes = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
     iTextSharp.text.Font times = new iTextSharp.text.Font(bfTimes, 12, iTextSharp.text.Font.ITALIC, BaseColor.DARK_GRAY);
     Document doc = new Document(iTextSharp.text.PageSize.LETTER,10,10,42,42);
     PdfWriter pdw = PdfWriter.GetInstance(doc, new FileStream(naziv + ".pdf", FileMode.Create));
     doc.Open();
     Paragraph p = new Paragraph("Word Count for : "+naziv,times);
     doc.Add(p);
     p.Alignment = 1;
     PdfPTable pdt = new PdfPTable(2);
     pdt.HorizontalAlignment = 1;
     pdt.SpacingBefore = 20f;
     pdt.SpacingAfter = 20f;
     pdt.AddCell("Word");
     pdt.AddCell("No of repetitions");
     foreach (Rijec r in lista_rijeci)
     {
         pdt.AddCell(r.Tekst);
         pdt.AddCell(Convert.ToString(r.Ponavljanje));
     }
     using (MemoryStream stream = new MemoryStream())
     {
         chart1.SaveImage(stream, ChartImageFormat.Png);
         iTextSharp.text.Image chartImage = iTextSharp.text.Image.GetInstance(stream.GetBuffer());
         chartImage.ScalePercent(75f);
         chartImage.Alignment = 1;
         doc.Add(chartImage);
     }
     doc.Add(pdt);
     doc.Close();
     MessageBox.Show("PDF created!");
 }
예제 #7
0
        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);
        }
        public static IElement GetElement(this HeaderBase hb)
        {
            Paragraph p = new Paragraph();

            Font f = TextSharpFonts.SectionHeaderFont;

            if (hb is TitleHeader)
            {
                f = TextSharpFonts.TitleHeaderFont;
                p.Add(new Phrase(hb.Header, f));
                p.Alignment = Element.ALIGN_CENTER;
                p.Leading = f.Size * 2f;
                p.SpacingAfter = f.Size * 1.5f;
            }

            if (hb is SectionHeader)
            {
                p.Add(new Phrase(hb.Header, f));
                p.Leading = f.Size * 1.5f;
            }

            if (hb is ItemHeader)
            {
                p.Add(new Phrase(hb.Header, TextSharpFonts.ItemHeaderFont));
            }

            return p;
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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
            }
        }
 public static Paragraph ParaRightBelowHeader(string content)
 {
     Paragraph msp = new Paragraph(content, FontConfig.ItalicFont);
     msp.Alignment = Element.ALIGN_CENTER;
     msp.SpacingAfter = 5;
     return msp;
 }
예제 #12
0
        public static bool generate(User user, string path)
        {
            document = new Document(PageSize.A4, 50, 50, 25, 25);

            var output = new MemoryStream();
            var writer = PdfWriter.GetInstance(document, new FileStream(path + "/BS-" + DateTime.Now.Month + "-" + DateTime.Now.Year + "-" + user.Firstname + "-" + user.Lastname + ".pdf", FileMode.Create));

            document.Open();

            // création du logo
            Image logo = iTextSharp.text.Image.GetInstance("logo.png");
            logo.ScaleAbsoluteWidth(200);
            logo.ScaleAbsoluteHeight(50);
            PdfPCell cellLogo = new PdfPCell(logo);
            cellLogo.Border = Rectangle.NO_BORDER;
            cellLogo.PaddingBottom = 8;

            // création du titre
            var title = new Paragraph("BULLETIN DE SALAIRE", titleFont);
            title.Alignment = Element.ALIGN_RIGHT;
            PdfPCell cellTitle = new PdfPCell(title);
            cellTitle.Border = Rectangle.NO_BORDER;
            cellTitle.HorizontalAlignment = 2; //0=Left, 1=Centre, 2=Right

            // création du tableau
            PdfPTable tableTitle = new PdfPTable(2);
            tableTitle.DefaultCell.Border = Rectangle.NO_BORDER;
            tableTitle.WidthPercentage = 100;

            PdfPCell cellAdresseSuperp = new PdfPCell(new Paragraph("89, quais des Chartrons \n33000 BORDEAUX", subTitleFont));
            cellAdresseSuperp.HorizontalAlignment = 0;
            cellAdresseSuperp.Border = Rectangle.NO_BORDER;

            PdfPCell cellDUMec = new PdfPCell(new Paragraph(user.Lastname + " " + user.Firstname + "\n" + user.Address, subTitleFont));
            cellDUMec.HorizontalAlignment = 2;
            cellDUMec.Border = Rectangle.NO_BORDER;

            // ajout de la cell du logo
            tableTitle.AddCell(cellLogo);

            // ajout de la cell du titre
            tableTitle.AddCell(cellTitle);

            tableTitle.AddCell(cellAdresseSuperp);
            tableTitle.AddCell(cellDUMec);

            // Ajout du titre principal
            tableTitle.AddCell(getTitle());

            //******************************************************************************/
            //***********************   ABSENCES   *****************************************/
            //******************************************************************************/

            generateAbsences(tableTitle, user);

            generateTableSalary(user);

            document.Close();
            return true;
        }
예제 #13
0
 public void AddHeader(string header)
 {
     Font myfont = getheaderFont();
     Paragraph headline = new Paragraph(header, myfont);
     headline.Alignment = 1;
     pdf.Add(headline);
 }
예제 #14
0
        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!");
            }
        }
 // ===========================================================================
 public void Write(Stream stream)
 {
     // step 1
     using (Document document = new Document())
     {
         // step 2
         PdfWriter.GetInstance(document, stream);
         document.SetPageSize(PageSize.A5);
         document.SetMargins(36, 72, 108, 180);
         document.SetMarginMirroring(true);
         // step 3
         document.Open();
         // step 4
         document.Add(new Paragraph(
           "The left margin of this odd page is 36pt (0.5 inch); " +
           "the right margin 72pt (1 inch); " +
           "the top margin 108pt (1.5 inch); " +
           "the bottom margin 180pt (2.5 inch).")
         );
         Paragraph paragraph = new Paragraph();
         paragraph.Alignment = Element.ALIGN_JUSTIFIED;
         for (int i = 0; i < 20; i++)
         {
             paragraph.Add("Hello World! Hello People! " +
             "Hello Sky! Hello Sun! Hello Moon! Hello Stars!"
             );
         }
         document.Add(paragraph);
         document.Add(new Paragraph(
           "The right margin of this even page is 36pt (0.5 inch); " +
           "the left margin 72pt (1 inch).")
         );
     }
 }
예제 #16
0
 // ---------------------------------------------------------------------------    
 /**
  * Creates a Paragraph containing information about a movie.
  * @param    movie    the movie for which you want to create a Paragraph
  */
 public Paragraph CreateMovieInformation(Movie movie)
 {
     Paragraph p = new Paragraph();
     p.Font = FilmFonts.NORMAL;
     p.Add(new Phrase("Title: ", FilmFonts.BOLDITALIC));
     p.Add(PojoToElementFactory.GetMovieTitlePhrase(movie));
     p.Add(" ");
     if (!string.IsNullOrEmpty(movie.OriginalTitle))
     {
         p.Add(new Phrase("Original title: ", FilmFonts.BOLDITALIC));
         p.Add(PojoToElementFactory.GetOriginalTitlePhrase(movie));
         p.Add(" ");
     }
     p.Add(new Phrase("Country: ", FilmFonts.BOLDITALIC));
     foreach (Country country in movie.Countries)
     {
         p.Add(PojoToElementFactory.GetCountryPhrase(country));
         p.Add(" ");
     }
     p.Add(new Phrase("Director: ", FilmFonts.BOLDITALIC));
     foreach (Director director in movie.Directors)
     {
         p.Add(PojoToElementFactory.GetDirectorPhrase(director));
         p.Add(" ");
     }
     p.Add(CreateYearAndDuration(movie));
     return p;
 }
예제 #17
0
파일: PdfTools.cs 프로젝트: gdlprj/duscusys
 public static void SingleLine(string str, Document document)
 {
     //document.Add(new Chunk(str));
     var p = new Paragraph(str);
     p.SpacingAfter = 7f;
     document.Add(p);
 }
예제 #18
0
        private void AddName(Project project, Document document)
        {
            var paragraph = new Paragraph(project.Name, HeaderFont());
            paragraph.SpacingAfter = 6f;

            document.Add(paragraph);
        }
예제 #19
0
        /* (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;
        }
예제 #20
0
 /**
  * Initialize one of the headers, based on the chapter title;
  * reset the page number.
  * @see com.itextpdf.text.pdf.PdfPageEventHelper#onChapter(
  *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document, float,
  *      com.itextpdf.text.Paragraph)
  */
 public override void OnChapter(
   PdfWriter writer, Document document,
   float paragraphPosition, Paragraph title)
 {
     header[1] = new Phrase(title.Content);
     pagenumber = 1;
 }
예제 #21
0
// ===========================================================================
    public void Write(Stream stream) {
      // step 1
      using (Document document = new Document(PageSize.POSTCARD, 30, 30, 30, 30)) {
        // step 2
        PdfWriter writer = PdfWriter.GetInstance(document, stream);
        writer.CompressionLevel = 0;
        // step 3
        document.Open();
        // step 4
        Image img = Image.GetInstance(Path.Combine(
          Utility.ResourceImage, "loa.jpg"
        ));
        img.SetAbsolutePosition(
          (PageSize.POSTCARD.Width - img.ScaledWidth) / 2,
          (PageSize.POSTCARD.Height - img.ScaledHeight) / 2
        );
        writer.DirectContent.AddImage(img);
        Paragraph p = new Paragraph(
          "Foobar Film Festival", 
          new Font(Font.FontFamily.HELVETICA, 22)
        );
        p.Alignment = Element.ALIGN_CENTER;
        document.Add(p);        
      }
    }
        public static void GeneratePdfReport(string filepath)
        {
            FileStream fileStream = new FileStream(filepath, FileMode.Create);
            Document document = new Document();
            PdfWriter writer = PdfWriter.GetInstance(document, fileStream);
            document.SetPageSize(PageSize.A3);
            document.Open();

            var paragraph = new Paragraph("Aggregated Sales Report",
                FontFactory.GetFont("Arial", 19, Font.BOLD));
            paragraph.SpacingAfter = 20.0f;
            paragraph.Alignment = 1;

            document.Add(paragraph);

            PdfPTable mainTable = new PdfPTable(1);
            var reports = GetDayReports();
            foreach (var dayReport in reports)
            {
                var headerCell = new PdfPCell(new Phrase("Date: " + dayReport.FormattedDate));
                headerCell.BackgroundColor = new BaseColor(175, 166, 166);
                mainTable.AddCell(headerCell);
                var table = GenerateReportTable(dayReport);
                mainTable.AddCell(table);
            }

            document.Add(mainTable);
            document.Close();
        }
예제 #23
0
 /// <summary>
 /// XMLWorker does not support RTL by default. so we need to collect the parsed elements first and
 /// then wrap them with a RTL table.
 /// </summary>
 public RtlElementsCollector()
 {
     _paragraph = new Paragraph
     {
         Alignment = Element.ALIGN_LEFT
     };
 }
        virtual public void SetUp() {
            parent = new Tag("body");
            parent.CSS[CSS.Property.FONT_FAMILY] = "Helvetica";
            parent.CSS[CSS.Property.FONT_SIZE] = "12pt";
            first = new Tag(null);
            first.CSS[CSS.Property.FONT_FAMILY] = "Helvetica";
            first.CSS[CSS.Property.FONT_SIZE] = "12pt";
            second = new Tag(null);
            second.CSS[CSS.Property.FONT_FAMILY] = "Helvetica";
            second.CSS[CSS.Property.FONT_SIZE] = "12pt";
            child = new Tag(null);
            child.CSS[CSS.Property.FONT_FAMILY] = "Helvetica";
            child.CSS[CSS.Property.FONT_SIZE] = "12pt";

            parent.AddChild(first);
            first.Parent = parent;
            second.Parent = parent;
            first.AddChild(child);
            second.AddChild(child);
            parent.CSS[CSS.Property.FONT_SIZE] = fst.TranslateFontSize(parent) + "pt";
            first.CSS[CSS.Property.FONT_SIZE] = fst.TranslateFontSize(first) + "pt";
            first.CSS[CSS.Property.TEXT_ALIGN] = CSS.Value.LEFT;
            second.CSS[CSS.Property.FONT_SIZE] = fst.TranslateFontSize(second) + "pt";
            child.CSS[CSS.Property.FONT_SIZE] = fst.TranslateFontSize(child) + "pt";
            firstPara = new Paragraph(new Chunk("default text for chunk creation"));
            secondPara = new Paragraph(new Chunk("default text for chunk creation"));
            configuration = new HtmlPipelineContext(null);
            applier.Apply(firstPara, first, configuration);
        }
예제 #25
0
 /// <summary>
 /// 获取段落
 /// </summary>
 /// <returns>返回格式化后的段落对象</returns>
 public static Paragraph GetParagraph()
 {
     Paragraph par = new Paragraph();
     par.SpacingBefore = 20;
     par.IndentationLeft = 65;
     return par;
 }
예제 #26
0
 public static Paragraph GetParagraph(int spaceTop)
 {
     Paragraph par = new Paragraph();
     par.SpacingBefore = spaceTop;
     par.IndentationLeft = 65;
     return par;
 }
 public static Paragraph ParaRightBeforeHeader(string content)
 {
     Paragraph msp = new Paragraph(content, FontConfig.SmallItalicFont);
     msp.IndentationLeft = 380;
     msp.Alignment = Element.ALIGN_LEFT;
     return msp;
 }
예제 #28
0
        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;
        }
예제 #29
0
        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();
        }
        //override the OnPageEnd event handler to add our footer
        public override void OnEndPage(PdfWriter writer, Document doc)
        {
            //I use a PdfPtable with 2 columns to position my footer where I want it
            PdfPTable footerTbl = new PdfPTable(2);

            //set the width of the table to be the same as the document
            footerTbl.TotalWidth = doc.PageSize.Width;

            //Center the table on the page
            footerTbl.HorizontalAlignment = Element.ALIGN_CENTER;

            //Create a paragraph that contains the footer text
            Paragraph para;// = new Paragraph("", Fuentes.footer);
            DateTime time = DateTime.Now;              // Use current time
            string format = "dd/MM/yyyy";    // Use this format
            para = new Paragraph(time.ToString(format), Fuentes.Footer);

            //add a carriage return
            para.Add(Environment.NewLine);
            para.Add("");

            //create a cell instance to hold the text
            PdfPCell cell = new PdfPCell(para);

            //set cell border to 0
            cell.Border = 0;

            //add some padding to bring away from the edge
            cell.PaddingLeft = 10;

            //add cell to table
            footerTbl.AddCell(cell);

            //Creo el contenido de la 2da celda
            int pageN = writer.PageNumber;
            //DateTime time = DateTime.Now;              // Use current time
            //string format = "dd/MM/yyyy";    // Use this format
            //para = new Paragraph(time.ToString(format), Fuentes.footer);

            //para.Add(Environment.NewLine);
            para = new Paragraph(pageN.ToString(), Fuentes.Footer);

            //create new instance of cell to hold the text
            cell = new PdfPCell(para);

            //align the text to the right of the cell
            cell.HorizontalAlignment = Element.ALIGN_RIGHT;
            //set border to 0
            cell.Border = 0;

            // add some padding to take away from the edge of the page
            cell.PaddingRight = 10;

            //add the cell to the table
            footerTbl.AddCell(cell);

            //write the rows out to the PDF output stream.
            footerTbl.WriteSelectedRows(0, -1, 0, (doc.BottomMargin + 10), writer.DirectContent);
        }
예제 #31
0
        public void createReport(String FileName, String Title, String[] ColumnNames, List <Obj> data)
        {
            //открываем файл для работы
            FileStream fs = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Write);

            //создаем документ, задаем границы, связываем документ и поток
            iTextSharp.text.Document doc = new iTextSharp.text.Document();
            doc.SetMargins(0.5f, 0.5f, 0.5f, 0.5f);
            PdfWriter writer = PdfWriter.GetInstance(doc, fs);

            doc.Open();
            BaseFont baseFont = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
            //вставляем заголовок
            var phraseTitle = new Phrase(Title,
                                         new iTextSharp.text.Font(baseFont, 16, iTextSharp.text.Font.BOLD));

            iTextSharp.text.Paragraph paragraph = new
                                                  iTextSharp.text.Paragraph(phraseTitle)
            {
                Alignment    = Element.ALIGN_CENTER,
                SpacingAfter = 12
            };
            doc.Add(paragraph);
            //вставляем таблицу, задаем количество столбцов, и ширину колонок
            PdfPTable table = new PdfPTable(2)
            {
                TotalWidth = 800F
            };

            table.SetTotalWidth(new float[] { 160, 140 });
            //вставляем шапку
            PdfPCell cell            = new PdfPCell();
            var      fontForCellBold = new iTextSharp.text.Font(baseFont, 10,
                                                                iTextSharp.text.Font.BOLD);

            table.AddCell(new PdfPCell(new Phrase(ColumnNames[0], fontForCellBold))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });
            table.AddCell(new PdfPCell(new Phrase(ColumnNames[1], fontForCellBold))
            {
                HorizontalAlignment = Element.ALIGN_CENTER
            });
            //заполняем таблицу
            var fontForCells = new iTextSharp.text.Font(baseFont, 10);

            for (int i = 0; i < data.Count; i++)
            {
                cell = new PdfPCell(new Phrase(data[i].Name, fontForCells));
                table.AddCell(cell);
                cell = new PdfPCell(new Phrase(data[i].Enum, fontForCells));
                table.AddCell(cell);
            }
            //вставляем таблицу
            doc.Add(table);
            doc.Close();
        }
예제 #32
0
        //简单使用
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Document  document  = new Document();
            PdfWriter pdfWriter = PdfWriter.GetInstance(document, new FileStream("简单使用.pdf",
                                                                                 FileMode.OpenOrCreate));

            document.Open();

            PdfContentByte cb = pdfWriter.DirectContent; //最上方

            //画线
            cb.SetLineWidth(2);
            cb.MoveTo(0, 0);  //以当前页左下角为原点
            cb.LineTo(200, 300);

            cb.Stroke();

            //在某个具体位置绘制文本
            BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252,
                                              BaseFont.NOT_EMBEDDED);

            cb.BeginText();
            cb.SetFontAndSize(bf, 12);
            cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "This text is centered",
                               0, 100, 0);
            cb.EndText();

            //为了测试,添加3章
            for (int i = 0; i < 10; i++)
            {
                //章节的标题
                Paragraph cTitle = new Paragraph($"This is chapter {i}", FontFactory.GetFont(
                                                     FontFactory.COURIER, 18));
                Chapter chapter = new Chapter(cTitle, i);

                //如果是偶数章节书签默认不打开
                if (i % 2 == 0)
                {
                    chapter.BookmarkOpen = false;
                }

                //每章添加2个区域
                for (int j = 0; j < 60; j++)
                {
                    //子区域
                    Paragraph sTitle = new Paragraph($"This is section {j} in chapter {i}",
                                                     FontFactory.GetFont(FontFactory.COURIER, 12, BaseColor.BLUE));

                    Section section = chapter.AddSection(sTitle, 2);  //第二个参数表示树的深度
                }

                document.Add(chapter);
            }

            document.Close();
            Title = "简单使用";
        }
예제 #33
0
        public void WriteContent(LineBean lb)
        {
            try
            {
                this.pdfViewer.CloseDocument();

                if (File.Exists(pFilePath))
                {
                    File.Delete(pFilePath);
                }

                FileStream myStream = new FileStream(pFilePath, FileMode.Create);              //文件流

                iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.A4); //创建A4纸、横向PDF文档
                PdfWriter writer = PdfWriter.GetInstance(document, myStream);                  //将PDF文档写入创建的文件中
                document.Open();


                //要在PDF文档中写入中文必须指定中文字体,否则无法写入中文
                BaseFont             bftitle   = BaseFont.CreateFont("C:\\Windows\\Fonts\\SIMHEI.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //用系统中的字体文件SimHei.ttf创建文件字体
                iTextSharp.text.Font fonttitle = new iTextSharp.text.Font(bftitle, 22);                                                             //标题字体,大小30
                                                                                                                                                    //单元格中的字体,大小12

                //添加标题
                iTextSharp.text.Paragraph Title = new iTextSharp.text.Paragraph(lb.OBSLINENAME + " 测线基本情况", fonttitle); //添加段落,第二个参数指定使用fonttitle格式的字体,写入中文必须指定字体否则无法显示中文
                Title.Alignment = iTextSharp.text.Rectangle.ALIGN_CENTER;                                               //设置居中
                document.Add(Title);                                                                                    //将标题段加入PDF文档中


                //空一行
                BaseFont                  bf1    = BaseFont.CreateFont("C:\\Windows\\Fonts\\SIMSUN.TTC,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //用系统中的字体文件SimSun.ttc创建文件字体
                iTextSharp.text.Font      ftitle = new iTextSharp.text.Font(bf1, 15);
                iTextSharp.text.Paragraph nullp  = new iTextSharp.text.Paragraph("      ", ftitle);
                document.Add(nullp);


                PdfPTable table = CreateTable(lb);

                document.Add(table); //将表格加入PDF文档中
                document.Close();
                myStream.Close();


                //    PDFOperation pdf = new PDFOperation();
                //pdf.Open(new FileStream(pFilePath, FileMode.Create));
                //pdf.SetBaseFont("C:\\WINDOWS\\FONTS\\STSONG.TTF");
                ////pdf.SetFont(20);
                //pdf.AddParagraph(sb.SiteName + " 跨断层监测场地基本情况", 15, 1, 20, 0, 0);
                //pdf.Close();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #34
0
        public static PdfPTable GetAllInfoTable()
        {
            PdfPTable table = new PdfPTable(4);

            table.WidthPercentage = 100f;
            table.SetWidths(new int[] { 1, 3, 2, 18 });

            PdfPCell cell;

            iTextSharp.text.Paragraph p;
            int rowNum       = 0;
            int textColumNum = 3;

            using (TextFieldParser parser = new TextFieldParser("../../Data/screen.csv", UTF8Encoding.UTF8, true))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");
                while (!parser.EndOfData)
                {
                    string[] fields = parser.ReadFields();
                    if (rowNum > 0)
                    {
                        for (int i = 0; i < textColumNum; i++)
                        {
                            p           = new iTextSharp.text.Paragraph(fields[i], new iTextSharp.text.Font(BF_Light, 10));
                            cell        = new PdfPCell(p);
                            cell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                            table.AddCell(cell);
                        }

                        string fileName = string.Format("../../Data/{0}.csv", fields[1]);
                        float  yMax     = float.Parse(fields[3]);
                        float  yScale   = float.Parse(fields[4]);


                        cell = new PdfPCell(new Phrase(""));
                        cell.MinimumHeight = 55f;
                        cell.Border        = iTextSharp.text.Rectangle.NO_BORDER;
                        //画图的类,和cell关联
                        ResolutionChart chart = new ResolutionChart(fileName, yMax, yScale);
                        cell.CellEvent = chart;
                        table.AddCell(cell);
                        rowNum++;
                    }
                    else
                    {
                        rowNum++;
                    }
                }
            }


            return(table);
        }
예제 #35
0
        private void PrintHeader(string text, Document doc)
        {
            var       phraseTitle = new Phrase(text, new Font(baseFont, 16, Font.BOLD));
            Paragraph paragraph   = new Paragraph(phraseTitle)
            {
                Alignment    = Element.ALIGN_CENTER,
                SpacingAfter = 12
            };

            doc.Add(paragraph);
        }
예제 #36
0
        private void ExportToPdf(DataGrid grid)
        {
            try
            {
                PdfPTable table       = new PdfPTable(grid.Columns.Count);
                Document  pdfcommande = new Document(iTextSharp.text.PageSize.A4.Rotate(), 6, 3, 3, 3);
                string    Directorio  = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                PdfWriter writer      = PdfWriter.GetInstance(pdfcommande, new FileStream(Directorio + "\\Informe.pdf", FileMode.Create));
                pdfcommande.Open();
                iTextSharp.text.Paragraph firstpara  = new iTextSharp.text.Paragraph("Informe de Prescripciones");
                iTextSharp.text.Paragraph firstpara2 = new iTextSharp.text.Paragraph(" ");
                foreach (DataGridColumn column in grid.Columns)
                {
                    table.AddCell(new Phrase(column.Header.ToString()));
                }
                table.HeaderRows = 1;
                IEnumerable itemsSource = grid.ItemsSource as IEnumerable;
                if (itemsSource != null)
                {
                    foreach (var item in itemsSource)
                    {
                        Entidades.PrescripcionPersonalizada ps = new Entidades.PrescripcionPersonalizada();
                        ps = (Entidades.PrescripcionPersonalizada)item;
                        if (ps != null)
                        {
                            table.AddCell(new Phrase(ps.idPrescripcion.ToString()));
                            table.AddCell(new Phrase(ps.rutPersona));
                            table.AddCell(new Phrase(ps.nomPersona));
                            table.AddCell(new Phrase(ps.diagnostico));
                            table.AddCell(new Phrase(ps.fechaPres.ToString()));
                            table.AddCell(new Phrase(ps.rutMedico));
                            table.AddCell(new Phrase(ps.nomMedico));
                            table.AddCell(new Phrase(ps.nomMedicamento));
                            table.AddCell(new Phrase(ps.formaFarmaceutica));
                            table.AddCell(new Phrase(ps.cantidad.ToString()));
                            table.AddCell(new Phrase(ps.estado));

                            /*float[] widths = new float[] { 150f, 150f, 150f, 160f, 160f, 160f, 160f, 160f, 160f, 160f, 160f };
                             * table.SetWidths(widths);*/
                        }
                    }
                    pdfcommande.Add(firstpara);
                    pdfcommande.Add(firstpara2);
                    pdfcommande.Add(table);
                    pdfcommande.Close();
                    writer.Close();
                    MessageBox.Show("Informe creado y enviado a escritorio en formato pdf");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("No se pudo Crear el informe");
            }
        }
예제 #37
0
        private void myWriteButton_Click(object sender, RoutedEventArgs e)
        {
            String fileName = SaveFileDialog();

            if (String.IsNullOrWhiteSpace(fileName))
            {
                return;
            }


            using (WaitDlg dlg = new WaitDlg())
            {
                Document document = new Document(PageSize.LETTER);

                //document.SetMargins(0, 0, 10, 0);
                // WORKING! document.SetMargins(document.LeftMargin, document.RightMargin, 25, 25);
                document.SetMargins(document.LeftMargin, document.RightMargin, 15, 10);


                PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create));


                // step 3: we open the document
                document.Open();



                iTextSharp.text.Paragraph paragraph = new iTextSharp.text.Paragraph();
                PdfPTable table = new pdf.PdfPTable(3);
                table.SpacingBefore = 0;
                table.SpacingAfter  = 10;
                table.TotalWidth    = 175.5f * 3.0f + 30f;
                table.LockedWidth   = true;


                List <Card> smallCards = GetSelectedCards(true, false);
                List <Card> bigCards   = GetSelectedCards(false, true);


                WriteCards(bigCards, table);
                WriteCards(smallCards, table);


                table.AddCell(new PdfPCell());
                table.AddCell(new PdfPCell());
                table.AddCell(new PdfPCell());

                document.Add(table);

                document.Close();
            }

            MessageBox.Show("PDF Generation Complete!");
        }
예제 #38
0
        private void button8_Click(object sender, RoutedEventArgs e)
        {
            Document  doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
            PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream("Test.pdf", FileMode.Create));

            doc.Open();
            iTextSharp.text.Paragraph paragraph = new iTextSharp.text.Paragraph("Mój wlasny test");

            doc.Add(paragraph);

            doc.Close();
        }
예제 #39
0
        private void PrintButton_Click(object sender, RoutedEventArgs e)
        {
            SalesGrid export = this.ListViewSales.SelectedItem as SalesGrid;

            if (export != null)
            {
                FileStream fs = new FileStream("..\\..\\ExportPdf" + "\\" + $"SaleId {export.SaleId} PDF Document.pdf", FileMode.Create);

                Document  document = new Document(PageSize.A6);
                PdfWriter writer   = PdfWriter.GetInstance(document, fs);
                document.Open();
                document.AddHeader("Date of sale", export.Date.ToString());
                document.AddAuthor(export.Seller);

                PdfContentByte        cb  = writer.DirectContent;
                iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance("..\\..\\Images\\avalon-mark.png");
                img.SetAbsolutePosition(180, 30);
                img.ScalePercent(40);
                cb.AddImage(img);

                Font calibri = new Font(Font.FontFamily.COURIER, 14, Font.ITALIC);

                iTextSharp.text.Paragraph p1 = new iTextSharp.text.Paragraph($"Data of sale: {export.Date.ToString()}", calibri);
                iTextSharp.text.Paragraph p2 = new iTextSharp.text.Paragraph($"Customer: {export.Customer}", calibri);
                iTextSharp.text.Paragraph p3 = new iTextSharp.text.Paragraph($"Number of beers: {export.BeersCount}", calibri);
                iTextSharp.text.Paragraph p4 = new iTextSharp.text.Paragraph($"Total Sale Price: {export.TotalSalePrice}$", calibri);
                iTextSharp.text.Paragraph p5 = new iTextSharp.text.Paragraph($"Total Bought Price: {export.TotalBoughtPrice}$", calibri);
                iTextSharp.text.Paragraph p6 = new iTextSharp.text.Paragraph($"Profit: {export.Profit}$", calibri);
                iTextSharp.text.Paragraph p7 = new iTextSharp.text.Paragraph($"Seller: {export.Seller}", calibri);

                document.Add(p1);
                document.Add(p2);
                document.Add(p3);
                document.Add(p4);
                document.Add(p5);
                document.Add(p6);
                document.Add(p7);

                document.Close();
                writer.Close();
                fs.Close();

                this.WarningLabel.Content    = $"Sale with id {export.SaleId} succesfully exported.";
                this.WarningLabel.Visibility = Visibility.Visible;
                ProcessStartInfo startInfo = new ProcessStartInfo("..\\..\\ExportPdf" + "\\" + $"SaleId {export.SaleId} PDF Document.pdf");
                Process.Start(startInfo);
            }
            else
            {
                this.WarningLabel.Content    = $"You should select sale first!";
                this.WarningLabel.Visibility = Visibility.Visible;
            }
        }
예제 #40
0
 internal void AddItemLine(string item, string subItems)
 {
     iText.Chunk itemChunck = new iText.Chunk(item);
     itemChunck.Font = iText.FontFactory.GetFont(baseFont, leadSize, iText.Font.BOLD, iText.BaseColor.BLACK);
     iText.Chunk subItemsChunck = new iText.Chunk(subItems);
     subItemsChunck.Font = iText.FontFactory.GetFont(baseFont, normalSize, iText.Font.NORMAL, iText.BaseColor.BLACK);
     iText.Phrase phrase = new iText.Phrase();
     phrase.Add(itemChunck);
     phrase.Add(subItemsChunck);
     iText.Paragraph paragraph = new iText.Paragraph(phrase);
     document.Add(paragraph);
 }
예제 #41
0
        public void saveDiagramm(string title, Chart chart)
        {
            if (MessageBox.Show("Напечатать отчет?", "Вопрос", MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.Yes)
            {
                SaveFileDialog sfd = new SaveFileDialog
                {
                    Filter = "pdf|*.pdf"
                };
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        string               FONT_LOCATION = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "arial.TTF"); //определяем В СИСТЕМЕ(чтобы не копировать файл) расположение шрифта arial.ttf
                        BaseFont             baseFont      = BaseFont.CreateFont(FONT_LOCATION, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);        //создаем шрифт
                        iTextSharp.text.Font fontParagraph = new iTextSharp.text.Font(baseFont, 17, iTextSharp.text.Font.NORMAL);                   //регистрируем + можно задать параметры для него(17 - размер, последний параметр - стиль)

                        var phraseTitle = new Phrase(title,
                                                     new iTextSharp.text.Font(baseFont, 18, iTextSharp.text.Font.BOLD));
                        iTextSharp.text.Paragraph paragraph = new
                                                              iTextSharp.text.Paragraph(phraseTitle)
                        {
                            Alignment    = Element.ALIGN_CENTER,
                            SpacingAfter = 12
                        };

                        chart.SaveImage(sfd.FileName + ".png", System.Drawing.Imaging.ImageFormat.Png);


                        Document document = new iTextSharp.text.Document(PageSize.A2, 10f, 10f, 10f, 0f);
                        using (var stream = new FileStream(sfd.FileName, FileMode.Create, FileAccess.Write, FileShare.None))

                        {
                            PdfWriter.GetInstance(document, stream);
                            document.Open();
                            using (var imageStream = new FileStream(sfd.FileName + ".png", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                            {
                                var image = Image.GetInstance(imageStream);
                                document.Add(paragraph);
                                document.Add(image);
                            }
                            document.Close();
                            File.Delete(sfd.FileName + ".png");
                        }
                    }
                    catch
                    {
                        MessageBox.Show("ERROR");
                    }
                }
            }
        }
예제 #42
0
        public void DrawString(string text, System.Drawing.Rectangle rect)
        {
            var bf = iTextSharp.text.pdf.BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, false);
            var f  = new Font(bf, 12);
            var p  = new iTextSharp.text.Paragraph(text);

            p.Font = f;
            var ct = new ColumnText(Canvas);

            ct.SetSimpleColumn(Transform2(rect));
            ct.AddElement(p);
            ct.Go();
        }
예제 #43
0
        public void ApplyNewLine()
        {
            if (this.CurrentLine.IsEmpty() == false)
            {
                var font = FontFactory.GetFont("courier", 8.2f, BaseColor.BLACK);
                var line = this.CurrentLine.ToString().TrimEndWhitespace();
                var para = new iTextSharp.text.Paragraph(line, font);
                para.SetLeading(0, 1.15f);
                this.Document.Add(para);
            }

            ClearCurrentLine();
        }
예제 #44
0
        public void savePDF(string FileName)
        {
            string   FONT_LOCATION = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "arial.TTF");
            BaseFont baseFont      = BaseFont.CreateFont(FONT_LOCATION, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font fontParagraph = new iTextSharp.text.Font(baseFont, 17, iTextSharp.text.Font.NORMAL);
            string title       = "Список выполненных заявок за период с " + dateTimePickerFrom.Text + " по " + dateTimePickerTo.Text;
            var    phraseTitle = new Phrase(title, new iTextSharp.text.Font(baseFont, 18, iTextSharp.text.Font.BOLD));

            iTextSharp.text.Paragraph paragraph = new
                                                  iTextSharp.text.Paragraph(phraseTitle)
            {
                Alignment    = Element.ALIGN_CENTER,
                SpacingAfter = 12
            };
            PdfPTable table = new PdfPTable(dataGridViewReport.Columns.Count - 1);

            for (int i = 0; i < dataGridViewReport.Columns.Count - 1; i++)
            {
                table.AddCell(new Phrase(dataGridViewReport.Columns[i + 1].HeaderCell.Value.ToString(), fontParagraph));
            }
            for (int i = 0; i < dataGridViewReport.Rows.Count; i++)
            {
                for (int j = 0; j < dataGridViewReport.Columns.Count - 1; j++)
                {
                    table.AddCell(new Phrase(dataGridViewReport.Rows[i].Cells[j + 1].FormattedValue.ToString(), fontParagraph));
                }
            }
            PdfPTable     table2 = new PdfPTable(dataGridViewReport.Columns.Count - 1);
            List <string> words  = new List <string>();

            string[] sum = { "", "", "", "", "ИТОГО : " };
            words.AddRange(sum);
            words.Add(textBoxItog.Text);
            for (int j = 0; j < words.Count; j++)
            {
                table2.AddCell(new Phrase(words[j], fontParagraph));
            }
            using (FileStream stream = new FileStream(FileName, FileMode.Create))
            {
                iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(PageSize.A2, 10f, 10f, 10f, 0f);
                PdfWriter.GetInstance(pdfDoc, stream);
                pdfDoc.Open();
                pdfDoc.Add(paragraph);
                pdfDoc.Add(table);
                pdfDoc.Add(table2);
                pdfDoc.Close();
                stream.Close();
            }
        }
예제 #45
0
 public void AddLine(string text, bool important)
 {
     iText.Chunk chunck = new iText.Chunk(text);
     if (important)
     {
         chunck.Font = iText.FontFactory.GetFont(baseFont, leadSize, iText.Font.BOLD, iText.BaseColor.BLACK);
     }
     else
     {
         chunck.Font = iText.FontFactory.GetFont(baseFont, normalSize, iText.Font.NORMAL, iText.BaseColor.BLACK);
     }
     iText.Paragraph paragraph = new iText.Paragraph(chunck);
     document.Add(paragraph);
 }
예제 #46
0
 private void ExportToPdfControl(DataGrid grid)
 {
     try
     {
         PdfPTable table       = new PdfPTable(grid.Columns.Count);
         Document  pdfcommande = new Document(iTextSharp.text.PageSize.A4.Rotate(), 6, 3, 3, 3);
         string    Directorio  = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
         PdfWriter writer      = PdfWriter.GetInstance(pdfcommande, new FileStream(Directorio + "\\Informe Control de Stock.pdf", FileMode.Create));
         pdfcommande.Open();
         iTextSharp.text.Paragraph firstpara  = new iTextSharp.text.Paragraph("Informe de Controles de Stock");
         iTextSharp.text.Paragraph firstpara2 = new iTextSharp.text.Paragraph(" ");
         foreach (DataGridColumn column in grid.Columns)
         {
             table.AddCell(new Phrase(column.Header.ToString()));
         }
         table.HeaderRows = 1;
         IEnumerable itemsSource = grid.ItemsSource as IEnumerable;
         if (itemsSource != null)
         {
             foreach (var item in itemsSource)
             {
                 Entidades.ControlStockInforme c = new Entidades.ControlStockInforme();
                 c = (Entidades.ControlStockInforme)item;
                 if (c != null)
                 {
                     table.AddCell(new Phrase(c.idControl.ToString()));
                     table.AddCell(new Phrase(c.nombre));
                     table.AddCell(new Phrase(c.descrip));
                     table.AddCell(new Phrase(c.fecha.ToString()));
                     table.AddCell(new Phrase(c.cantidad.ToString()));
                     table.AddCell(new Phrase(c.rutFar));
                     table.AddCell(new Phrase(c.nombres));
                     table.AddCell(new Phrase(c.idMedica.ToString()));
                     table.AddCell(new Phrase(c.nombreMed));
                 }
             }
             pdfcommande.Add(firstpara);
             pdfcommande.Add(firstpara2);
             pdfcommande.Add(table);
             pdfcommande.Close();
             writer.Close();
             MessageBox.Show("Informe creado y enviado a escritorio en formato pdf");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("No se pudo Crear el informe");
     }
 }
예제 #47
0
        public void CreateInvoice(List <OrderedProductsStorage> orderedProducts, InvoiceComponents pdfInvoice, Invoices invoice, int orderId)
        {
            pdfInvoice.InvoiceNumber = GenerateInvoiceNumber();
            pdfInvoice.InvoiceDate   = invoice.InvoiceDate;
            invoice.InvoiceNumber    = pdfInvoice.InvoiceNumber;

            string StartPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string path      = $"\\Invoice{pdfInvoice.InvoiceNumber}.pdf";

            Document  doc       = new Document(PageSize.LETTER, 10, 10, 25, 15);
            PdfWriter pdfWriter = PdfWriter.GetInstance(doc, new FileStream(StartPath + path, FileMode.Create));

            doc.Open();

            iTextSharp.text.Paragraph paragraph = new iTextSharp.text.Paragraph(CreateDataString(
                                                                                    pdfInvoice,
                                                                                    orderId
                                                                                    ));

            PdfPTable table = new PdfPTable(3)
            {
                TotalWidth  = 260f,
                LockedWidth = true
            };

            float[] widths = new float[] { 1f, 1f, 1f };
            table.SetWidths(widths);
            table.HorizontalAlignment = 1;
            table.AddCell(new Phrase("Product Name"));
            table.AddCell(new Phrase("Quantity"));
            table.AddCell(new Phrase("Value"));

            PdfPCell cell = new PdfPCell();

            //cell = new PdfPCell(new Phrase("Products"));
            cell.HorizontalAlignment = 1;

            for (int i = 0; i < orderedProducts.Count; i++)
            {
                table.AddCell(orderedProducts[i].ProductName);
                table.AddCell(orderedProducts[i].Quantity.ToString());
                table.AddCell(orderedProducts[i].OrderedValue.ToString());
            }

            doc.Add(paragraph);
            doc.Add(table);
            doc.Close();
            AddInvoiceToDatabase(invoice, orderId);
        }
예제 #48
0
        public void getPrintResult()
        {
            Document  doc    = new Document();
            PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream("Receipt.pdf", FileMode.Create));

            doc.Open();
            PdfContentByte content = writer.DirectContent;

            //Getting Image

            iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance("../../Resources/ReceiptHeader.png");
            image.ScaleAbsolute(140f, 30f);
            image.Alignment = Element.ALIGN_CENTER;

            doc.Add(image);


            // Setting Text paragraph
            iTextSharp.text.Font fdefault = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);

            iTextSharp.text.Paragraph paragraph = new iTextSharp.text.Paragraph("Your Queue Number is:", fdefault);
            paragraph.Alignment = Element.ALIGN_CENTER;
            doc.Add(paragraph);

            fdefault            = FontFactory.GetFont("Arial", 24, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
            paragraph           = new iTextSharp.text.Paragraph(label8.Text, fdefault);
            paragraph.Alignment = Element.ALIGN_CENTER;
            doc.Add(paragraph);

            fdefault            = FontFactory.GetFont("Arial", 6, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
            paragraph           = new iTextSharp.text.Paragraph("\nPlease wait for your number.", fdefault);
            paragraph.Alignment = Element.ALIGN_CENTER;
            doc.Add(paragraph);

            paragraph           = new iTextSharp.text.Paragraph(getTransactionOffices(), fdefault);
            paragraph.Alignment = Element.ALIGN_CENTER;
            doc.Add(paragraph);

            content.Rectangle(225f, 690f - addHeight, 150f, 120f + addHeight);
            content.Stroke();

            //iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(new Uri(path));

            //doc.Add(image);

            doc.Close();

            System.Diagnostics.Process.Start("Receipt.pdf");
        }
예제 #49
0
        public static iTextSharp.text.pdf.PdfPCell AddText2Cell(iTextSharp.text.Paragraph para)
        {
            const string METHOD_NAME = "AddText2Cell";

            try {
                iTextSharp.text.pdf.PdfPCell cell = new iTextSharp.text.pdf.PdfPCell(para);
                cell.BorderWidth = 0;

                return(cell);
            }
            catch (Exception ex) {
                ApplicationException aex = new ApplicationException(MOD_NAME + METHOD_NAME, ex);
                throw (aex);
            }
        }
예제 #50
0
        /**
         * Dit maakt de opzet voor het overzicht PDF, het werkelijke rooster wordt gemaakt in een aparte functie.
         */
        public void CreateOverviewPDF(String filename)
        {
            // het document(standaard A4-formaat) maken en in landscape mode zetten
            iTextSharp.text.Document document = new iText.Document(PageSize.A4.Rotate());

            try
            {
                // De writer maken die naar het document luistert en zet de stream om in een PDF-bestand
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));

                // het document openen
                document.Open();

                // Een titel maken
                iText.Paragraph titel = new iText.Paragraph("Het afstudeerzittingen rooster", FontFactory.GetFont("Arial", 26, Font.BOLDITALIC));
                titel.Alignment = 1; // titel centeren

                // elementen toevoegen aan het document
                document.Add(titel);                    // de titel toevoegen
                document.Add(new iText.Paragraph(" ")); // leegruimte toevoegen
                document.Add(new iText.Paragraph(" ")); // leegruimte toevoegen

                PdfPTable rosterTable = MakeRoster();
                if (rosterTable == null)
                {
                    MessageBox.Show("Exporteren is mislukt, het overzicht bevat geen records!", "Melding");
                    return;
                }

                document.Add(rosterTable); // het rooster

                // toon bericht dat exporteren naar PDF gelukt is
                MessageBox.Show("Exporteren gelukt! Bestand is geëxporteerd naar " + filename, "Melding");

                // open het PDF-bestand
                System.Diagnostics.Process.Start(filename);
            }
            catch (PdfException ex)
            {
                // toon bericht als er iets fout gaat
                MessageBox.Show(ex.Message);
            }
            finally
            {
                // het document sluiten
                document.Close();
            }
        }
예제 #51
0
        public void DrawString(string text, System.Drawing.Rectangle rect, float fontsize, System.Drawing.Color color)
        {
            Canvas.SetRGBColorFill(color.R, color.G, color.B);
            var bf = iTextSharp.text.pdf.BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, false);
            var f  = new Font(bf, fontsize);

            var p = new iTextSharp.text.Paragraph(text);

            p.Font    = f;
            p.Leading = fontsize;
            var ct = new ColumnText(Canvas);

            ct.SetSimpleColumn(Transform2(rect));
            ct.AddElement(p);
            ct.Go();
        }
예제 #52
0
    private PdfPCell CreoCelda(string Texto, int Alineacion)
    {
        iTextSharpText.Paragraph texto = new iTextSharpText.Paragraph();
        texto.Font = iTextSharpText.FontFactory.GetFont("Arial", 7, iTextSharpText.Element.ALIGN_CENTER);

        texto.Add(Texto);

        PdfPCell c = new PdfPCell(texto);

        c.HorizontalAlignment = Alineacion;

        c.Padding    = 3;
        c.PaddingTop = 0;

        return(c);
    }
예제 #53
0
        public Document Remplir_doc(Document doc, String nom, String adresse, String spec, String etat, int id_m, int id_dm)
        {
            String[] Med  = Recuperer_info_Docteur(id_m);
            String[] Pat  = Recuperer_info_pat(id_dm);
            DateTime date = DateTime.Now;

            iTextSharp.text.Font f1 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 15f, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLACK);
            iTextSharp.text.Font f2 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 15f, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLACK);
            iTextSharp.text.Font b  = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 20f, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.BLACK);
            iTextSharp.text.Font b1 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12f, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLACK);



            Paragraph par1   = new Paragraph(" Lieu :" + Med[3], f1);
            Paragraph par2   = new Paragraph(" Téléphone :" + Med[5], f1);
            Paragraph par3   = new Paragraph(" Email :" + Med[4], f1);
            String    d      = date.Day.ToString() + "/" + date.Month.ToString() + "/" + date.Year.ToString();
            Paragraph parag0 = new Paragraph("\nLe: " + d + "\n", b1);

            parag0.Alignment = Element.ALIGN_RIGHT;
            doc.Add(par1);
            doc.Add(par2);
            doc.Add(par3);
            doc.Add(parag0);



            Paragraph parag = new iTextSharp.text.Paragraph(" \nLettre d'orientation\n\n", b);

            parag.Alignment = Element.ALIGN_CENTER;

            Paragraph parag1 = new Paragraph("\nDu docteur : " + Med[0] + " " + Med[1] + "           Spécialité : " + Med[2] + ".", b1);
            Paragraph parag2 = new Paragraph("\n Au docteur : " + nom + "         Spécialité : " + spec + "       Adresse :" + adresse + ".", b1);
            Paragraph parag3 = new Paragraph("\n\n                                Mon cher confrère,\n       Je vous adresse le patient : " + Pat[0] + " " + Pat[1] + " qui a " + Pat[2] + ".\n       Son état de santé: " + etat + ". \n\n Je vous l'adresse pour avis et je vous remercie de l'attention que vous lui portez .", b1);

            /* Chunk parax = new Chunk("Allah ", FontFactory.GetFont("Times New Roman"));
             * parax.Font.Size = 14;
             * doc.Add(parax);*/


            doc.Add(parag);
            doc.Add(parag1);
            doc.Add(parag2);
            doc.Add(parag3);
            doc.Add(new Paragraph("\n\n                                                                                        Signature: ", b1));
            return(doc);
        }
예제 #54
0
 private void ExportToPdf(DataGrid grid)
 {
     try
     {
         PdfPTable table       = new PdfPTable(grid.Columns.Count);
         Document  pdfcommande = new Document(iTextSharp.text.PageSize.A4.Rotate(), 6, 3, 3, 3);
         string    Directorio  = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
         PdfWriter writer      = PdfWriter.GetInstance(pdfcommande, new FileStream(Directorio + "\\Informe Medicamentos.pdf", FileMode.Create));
         pdfcommande.Open();
         iTextSharp.text.Paragraph firstpara  = new iTextSharp.text.Paragraph("Informe de Medicamentos");
         iTextSharp.text.Paragraph firstpara2 = new iTextSharp.text.Paragraph(" ");
         foreach (DataGridColumn column in grid.Columns)
         {
             table.AddCell(new Phrase(column.Header.ToString()));
         }
         table.HeaderRows = 1;
         IEnumerable itemsSource = grid.ItemsSource as IEnumerable;
         if (itemsSource != null)
         {
             foreach (var item in itemsSource)
             {
                 Entidades.Medicamento m = new Entidades.Medicamento();
                 m = (Entidades.Medicamento)item;
                 if (m != null)
                 {
                     table.AddCell(new Phrase(m.idMedicamento.ToString()));
                     table.AddCell(new Phrase(m.nombreComercial));
                     table.AddCell(new Phrase(m.laboratorio));
                     table.AddCell(new Phrase(m.ean13));
                     table.AddCell(new Phrase(m.formaFarmaceutica));
                     table.AddCell(new Phrase(m.stock.ToString()));
                     table.AddCell(new Phrase(m.idSucursal.ToString()));
                 }
             }
             pdfcommande.Add(firstpara);
             pdfcommande.Add(firstpara2);
             pdfcommande.Add(table);
             pdfcommande.Close();
             writer.Close();
             MessageBox.Show("Informe creado y enviado a escritorio en formato pdf");
         }
     }
     catch (Exception)
     {
         MessageBox.Show("No se pudo Crear el informe");
     }
 }
예제 #55
0
        public bool ShowReceptPDF(Proizvod proizvod)
        {
            using (iTextSharp.text.Document doc = new iTextSharp.text.Document(PageSize.A4))
            {
                try
                {
                    string fileName = proizvod.Naziv.Replace(" ", "_") + "_recept.pdf";
                    PdfWriter.GetInstance(doc, new FileStream(fileName, FileMode.Create));
                    doc.Open();
                    string recept = "OSNOVNI PODACI:\n" +
                                    "Naziv: " + proizvod.Naziv + "\n" +
                                    "Tezina: " + proizvod.Tezina + "\n" +
                                    "Cena: " + proizvod.Cena + "\n" +
                                    "Napomena: " + proizvod.Napomena + "\n\n\n" +
                                    "SASTOJCI:\n";

                    int i = 1;
                    foreach (Sastojak sastojak in proizvod.GetSastojci())
                    {
                        recept += i + ". " + sastojak.GetKategorija().Naziv + " - " + sastojak.GetRoba().Naziv + " -> " + sastojak.Kolicina + "\n";
                        i++;
                    }

                    recept += "\n\n\nKORACI:\n";
                    foreach (Korak korak in proizvod.GetKoraci())
                    {
                        recept += korak.Redni_broj + ". korak: " + korak.Opis + "\n";
                    }

                    iTextSharp.text.Paragraph p = new iTextSharp.text.Paragraph("RECEPT");
                    p.Alignment = Element.ALIGN_CENTER;
                    doc.Add(p);

                    doc.Add(new iTextSharp.text.Paragraph(50, " "));
                    doc.Add(new iTextSharp.text.Paragraph(recept));
                    string path = Directory.GetCurrentDirectory() + "\\" + fileName;
                    Process.Start(path);

                    return(false);
                }
                catch
                {
                    return(true);
                }
            }
        }
예제 #56
0
        public Document Remplir_doc(Document doc, string com, int i, string period, int id_m, int id_dm)
        {
            MiseEnFormLettre forme = new MiseEnFormLettre(id_dm, id_m);

            String[] Med  = forme.Recuperer_info_Docteur(id_m);
            String[] Pat  = forme.Recuperer_info_pat(id_dm);
            DateTime date = DateTime.Now;

            iTextSharp.text.Font f1 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 15f, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLACK);
            iTextSharp.text.Font b  = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 20f, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.BLACK);
            iTextSharp.text.Font b1 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 12f, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLACK);


            Paragraph par1   = new Paragraph("Lieu :" + Med[3], f1);
            Paragraph par2   = new Paragraph(" Téléphone :" + Med[5], f1);
            Paragraph par3   = new Paragraph(" Email :" + Med[4], f1);
            String    d      = date.Day.ToString() + "/" + date.Month.ToString() + "/" + date.Year.ToString();
            Paragraph parag0 = new Paragraph("\nLe " + d + "\n\n", b1);

            parag0.Alignment = Element.ALIGN_RIGHT;


            doc.Add(par1);
            doc.Add(par2);
            doc.Add(par3);
            doc.Add(parag0);


            Paragraph parag = new iTextSharp.text.Paragraph("Certificat Medical\n", b);

            parag.Alignment = Element.ALIGN_CENTER;

            Paragraph parag1 = new Paragraph("\n\n\n Docteur :" + Med[0] + " " + Med[1] + "            Spécialité : " + Med[2], b1);
            Paragraph parag2 = new Paragraph("\n\n Je soussigné , Docteur :" + Med[0] + " " + Med[1] + " , certifie que l'état de santé de : M." + Pat[0] + " " + Pat[1], b1);
            Paragraph parag3 = new Paragraph("\nNécessite un traitement avec arret de travail de : " + i + " " + period + " à partir de : " + d, b1);
            Paragraph parag4 = new Paragraph("\n\n\n\n\n                                                                                         Signature :", b1);

            doc.Add(parag);

            doc.Add(parag1);
            doc.Add(parag2);
            doc.Add(parag3);
            doc.Add(parag4);
            return(doc);
        }
예제 #57
0
        private void generatePDF(List <transactions> list, string period)
        {
            using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
            {
                string   filename  = "raport_" + DateTime.Now.ToString("ddMMyyyy") + "_" + DateTime.Now.ToString("hhmmss") + ".pdf";
                string   file_path = "C:\\Python Projects\\" + filename;
                Document document  = new Document(PageSize.A4, 10, 10, 10, 10);
                Console.WriteLine(file_path);
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(file_path, FileMode.Create));
                document.Open();

                Paragraph para = new Paragraph("RAPORT FINANSOWY ZA " + period)
                {
                    Font      = FontFactory.GetFont(FontFactory.TIMES_BOLD, 16f, Font.BOLD),
                    Alignment = Element.ALIGN_CENTER
                };
                document.Add(para);

                PdfPTable table = new PdfPTable(6);

                foreach (var i in list)
                {
                    Helper temp = new Helper(i.id.ToString(), i.datetime, i.car, i.price.ToString(), i.balance.ToString(), i.filename);
                    //string text = i.id + "  " + i.datetime + "  " + i.car + "  " + i.price + "  " + i.balance + "  " + i.filename;
                    foreach (PropertyInfo propertyInfo in temp.GetType().GetProperties())
                    {
                        table.AddCell(propertyInfo.GetValue(temp).ToString());
                    }
                }

                document.Add(table);
                document.Close();
                byte[] bytes = memoryStream.ToArray();
                memoryStream.Close();

                try
                {
                    System.Diagnostics.Process.Start(file_path);
                }
                catch
                {
                    MessageBox.Show("Aby przeglądać/drukować umowy musisz zainstalować program Acrobat Reader! Umowa jest dostępna w katalogu 'umowy'");
                }
            }
        }
예제 #58
0
        void WriteHeader(iTextSharp.text.Document doc)
        {
            iTextSharp.text.pdf.draw.LineSeparator line = new iTextSharp.text.pdf.draw.LineSeparator(2f, 100f, iTextSharp.text.BaseColor.BLACK, iTextSharp.text.Element.ALIGN_CENTER, -1);
            iTextSharp.text.Chunk linebreak             = new iTextSharp.text.Chunk(line);
            iTextSharp.text.Font  black = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.COURIER, 9f, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.BLACK);
            var logo = new iTextSharp.text.Paragraph()
            {
                Alignment = 0
            };

            logo.Add(new iTextSharp.text.Chunk("Graph", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 36, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK)));
            logo.Add(new iTextSharp.text.Chunk("SEA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 36, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(26, 188, 156))));
            doc.Add(logo);
            doc.Add(new iTextSharp.text.Chunk(line));
            // add front page
            doc.Add(new Paragraph(new iTextSharp.text.Chunk("GraphSEA", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.COURIER, 72, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(26, 188, 156)))));
            doc.Add(new Paragraph(new iTextSharp.text.Chunk("Graph Search Algorithms Benchmark Report", new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.COURIER, 36, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK))));
        }
예제 #59
0
        /// <summary>
        ///  XMLWorker RTL sample.
        /// </summary>
        /// <param name="args"></param>
        ///
        public static PdfPCell GetRichCell(string html)
        {
            var cell = new PdfPCell {
                Border = 0,
                HorizontalAlignment = Element.ALIGN_LEFT
            };

            iTextSharp.text.Paragraph p = new iTextSharp.text.Paragraph();
            TextReader sr = new StringReader(html);

            // XMLWorkerHelper.GetInstance().ParseXHtml(elementsHandler, sr);
            System.Collections.Generic.List <IElement> htmlArrayList = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(new StringReader(html), null);
            p.SetLeading(0.1f, 0f);
            p.InsertRange(0, htmlArrayList);
            cell.AddElement(p);
            cell.PaddingLeft = 4;
            return(cell);
        }
예제 #60
0
        public static iTextSharp.text.pdf.PdfPCell AddText2Table(PdfPTable table, iTextSharp.text.Paragraph para, int colSpan)
        {
            const string METHOD_NAME = "AddText2Table";

            try {
                iTextSharp.text.pdf.PdfPCell cell = new iTextSharp.text.pdf.PdfPCell(para);
                cell.BorderWidth = 0;
                cell.Colspan     = colSpan;

                table.AddCell(cell);

                return(cell);
            }
            catch (Exception ex) {
                ApplicationException aex = new ApplicationException(MOD_NAME + METHOD_NAME, ex);
                throw (aex);
            }
        }