Esempio n. 1
0
        public virtual void CreatePdf(String dest)
        {
            PdfDocument pdf      = new PdfDocument(new PdfWriter(dest));
            Document    document = new Document(pdf, PageSize.A4.Rotate());

            float[]         stops     = new float[] { 80, 120, 430, 640, 720 };
            IList <TabStop> tabstops  = new List <TabStop>();
            PdfCanvas       pdfCanvas = new PdfCanvas(pdf.AddNewPage());

            for (int i = 0; i < stops.Length; i++)
            {
                tabstops.Add(new TabStop(stops[i]));
                pdfCanvas.MoveTo(document.GetLeftMargin() + stops[i], 0);
                pdfCanvas.LineTo(document.GetLeftMargin() + stops[i], 595);
            }
            pdfCanvas.Stroke();
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            foreach (IList <String> record in resultSet)
            {
                Paragraph p = new Paragraph();
                p.AddTabStops(tabstops);
                p.Add(record[0].Trim()).Add(new Tab()).Add(record[1].Trim()).Add(new Tab()).Add(record[2].Trim()).Add(new
                                                                                                                      Tab()).Add(record[3].Trim()).Add(new Tab()).Add(record[4].Trim()).Add(new Tab()).Add(record[5].Trim());
                document.Add(p);
            }
            document.Close();
        }
Esempio n. 2
0
        public virtual void CreatePdf(String dest)
        {
            PdfDocument pdf      = new PdfDocument(new PdfWriter(dest));
            Document    document = new Document(pdf, PageSize.A4.Rotate());
            Table       table    = new Table(UnitValue.CreatePercentArray(new float[] { 3, 2, 14, 9, 4, 3 }))
                                   .UseAllAvailableWidth();
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");
            IList <String>          header    = resultSet[0];

            resultSet.RemoveAt(0);
            foreach (String field in header)
            {
                table.AddHeaderCell(field);
            }
            foreach (IList <String> record in resultSet)
            {
                foreach (String field_1 in record)
                {
                    table.AddCell(field_1);
                }
            }
            Table outerTable = new Table(UnitValue.CreatePercentArray(1)).UseAllAvailableWidth()
                               .AddHeaderCell("Continued from previous page:").SetSkipFirstHeader(true)
                               .AddCell(new Cell().Add(table).SetPadding(0));

            document.Add(outerTable);
            document.Close();
        }
        public virtual void CreatePdf(String dest)
        {
            PdfDocument pdf      = new PdfDocument(new PdfWriter(dest));
            Document    document = new Document(pdf);
            Paragraph   p        = new Paragraph().Add("Go to last page").SetAction(PdfAction.CreateNamed(PdfName.LastPage));

            document.Add(p);
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            resultSet.RemoveAt(0);
            List list = new List(ListNumberingType.DECIMAL);

            foreach (IList <String> record in resultSet)
            {
                ListItem li = new ListItem();
                li.SetKeepTogether(true);
                li.Add(new Paragraph().SetFontSize(14).Add(record[2])).Add(new Paragraph(String.Format("Directed by {0} ({1}, {2})"
                                                                                                       , record[3], record[4], record[1])));
                FileInfo file = new FileInfo(String.Format("../../../resources/img/{0}.jpg", record[0]));
                if (file.Exists)
                {
                    iText.Layout.Element.Image img = new Image(ImageDataFactory.Create(file.FullName));
                    img.ScaleToFit(10000, 120);
                    li.Add(img);
                }
                list.Add(li);
            }
            document.Add(list);
            p = new Paragraph().Add("Go to first page").SetAction(PdfAction.CreateNamed(PdfName.FirstPage));
            document.Add(p);
            document.Close();
        }
Esempio n. 4
0
        public virtual void CreatePdf(String dest)
        {
            //Initialize PDF document
            PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
            // Initialize document
            Document document = new Document(pdf, PageSize.A4.Rotate());
            Table    table    = new Table(UnitValue.CreatePercentArray(new float[] { 3, 32 }))
                                .UseAllAvailableWidth();
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            resultSet.RemoveAt(0);
            table.AddHeaderCell("imdb").AddHeaderCell("Information about the movie");
            Cell cell;

            foreach (IList <String> record in resultSet)
            {
                table.AddCell(record[0]);
                cell = new Cell().Add(new Paragraph(record[1])).Add(new Paragraph(record[2])).Add(new Paragraph(record[3])
                                                                                                  ).Add(new Paragraph(record[4])).Add(new Paragraph(record[5]));
                cell.SetKeepTogether(true);
                table.AddCell(cell);
            }
            document.Add(table);
            document.Close();
        }
        public virtual void CreatePdf(String dest)
        {
            //Initialize PDF document
            PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
            // Initialize document
            Document document = new Document(pdf, PageSize.A4.Rotate());
            Table    table    = new Table(UnitValue.CreatePercentArray(new float[] { 3, 2, 14, 9, 4, 3 }))
                                .UseAllAvailableWidth();
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");
            IList <String>          header    = resultSet[0];

            resultSet.RemoveAt(0);
            foreach (String field in header)
            {
                table.AddHeaderCell(field);
            }
            foreach (IList <String> record in resultSet)
            {
                table.AddCell(record[0]);
                table.AddCell(record[1]);
                Cell cell = new Cell().Add(new Paragraph(record[2]));
                cell.SetNextRenderer(new C05E14_JekyllHydeTableV7.RunlengthRenderer(cell, record[5]));
                table.AddCell(cell);
                table.AddCell(record[3]);
                table.AddCell(record[4]);
                table.AddCell(record[5]);
            }
            document.Add(table);
            document.Close();
        }
Esempio n. 6
0
        public virtual void CreatePdf(String dest)
        {
            PdfDocument             pdf       = new PdfDocument(new PdfWriter(dest));
            Document                document  = new Document(pdf);
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            resultSet.RemoveAt(0);
            foreach (IList <String> record in resultSet)
            {
                Div div = new Div().SetKeepTogether(true).SetBorderLeft(new SolidBorder(2)).SetPaddingLeft(3).SetMarginBottom
                              (10);
                String url   = String.Format("http://www.imdb.com/title/tt{0}", record[0]);
                Link   movie = new Link(record[2], PdfAction.CreateURI(url));
                div.Add(new Paragraph(movie.SetFontSize(14))).Add(new Paragraph(String.Format("Directed by {0} ({1}, {2})", record
                                                                                              [3], record[4], record[1])));
                FileInfo file = new FileInfo(String.Format("../../../resources/img/{0}.jpg", record[0]));
                if (file.Exists)
                {
                    iText.Layout.Element.Image img = new Image(ImageDataFactory.Create(file.FullName));
                    img.ScaleToFit(10000, 120);
                    div.Add(img);
                }
                document.Add(div);
            }
            document.Close();
        }
Esempio n. 7
0
        public virtual void CreatePdf(String dest)
        {
            PdfDocument pdf = new PdfDocument(new PdfWriter(dest));

            pdf.AddNewPage();
            pdf.GetCatalog().SetPageMode(PdfName.UseOutlines);
            PdfOutline root = pdf.GetOutlines(false);
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            resultSet.RemoveAt(0);
            foreach (IList <String> record in resultSet)
            {
                PdfOutline movie = root.AddOutline(record[2]);
                PdfOutline imdb  = movie.AddOutline("Link to IMDB");
                imdb.SetColor(ColorConstants.BLUE);
                imdb.SetStyle(PdfOutline.FLAG_BOLD);
                String url = String.Format("http://www.imdb.com/title/tt{0}", record[0]);
                imdb.AddAction(PdfAction.CreateURI(url));
                PdfOutline info = movie.AddOutline("More info:");
                info.SetOpen(false);
                info.SetStyle(PdfOutline.FLAG_ITALIC);
                PdfOutline director = info.AddOutline("Directed by " + record[3]);
                director.SetColor(ColorConstants.RED);
                PdfOutline place = info.AddOutline("Produced in " + record[4]);
                place.SetColor(ColorConstants.MAGENTA);
                PdfOutline year = info.AddOutline("Released in " + record[1]);
                year.SetColor(ColorConstants.DARK_GRAY);
            }
            pdf.Close();
        }
Esempio n. 8
0
        public virtual void CreatePdf(String dest)
        {
            //Initialize PDF document
            PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
            // Initialize document
            Document document = new Document(pdf, PageSize.A4.Rotate());
            Table    table    = new Table(UnitValue.CreatePercentArray(new float[] { 3, 2, 14, 9, 4, 3 })).UseAllAvailableWidth();
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            IList <String> header = resultSet[0];

            resultSet.RemoveAt(0);
            foreach (String field in header)
            {
                table.AddHeaderCell(field);
            }
            Cell cell = new Cell(1, 6).Add(new Paragraph("Continued on next page..."));

            table.AddFooterCell(cell).SetSkipLastFooter(true);
            foreach (IList <String> record in resultSet)
            {
                foreach (String field_1 in record)
                {
                    table.AddCell(field_1);
                }
            }
            document.Add(table);
            document.Close();
        }
Esempio n. 9
0
        public virtual void CreatePdf(String dest)
        {
            //Initialize PDF document
            PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
            // Initialize document
            Document document = new Document(pdf, PageSize.A4.Rotate());
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");
            IList <String>          header    = resultSet[0];

            resultSet.RemoveAt(0);
            Table table = new Table(UnitValue.CreatePercentArray(new float[] { 3, 2, 14, 9, 4, 3 }));

            table.SetWidth(UnitValue.CreatePercentValue(100));
            int nRows = resultSet.Count;

            table.SetNextRenderer(new AlternatingBackgroundTableRenderer(table, new Table.RowRange(0, nRows - 1)));
            foreach (String field in header)
            {
                table.AddHeaderCell(field);
            }

            foreach (IList <String> record in resultSet)
            {
                foreach (String field_1 in record)
                {
                    table.AddCell(field_1);
                }
            }

            document.Add(table);
            document.Close();
        }
Esempio n. 10
0
        public virtual void CreatePdf(String dest)
        {
            //Initialize PDF document
            PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
            // Initialize document
            Document document = new Document(pdf, PageSize.A4.Rotate());
            Table    table    = new Table(UnitValue.CreatePercentArray(new float[] { 3, 2, 14, 9, 4, 3 }));
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");
            IList <String>          header    = resultSet[0];

            resultSet.RemoveAt(0);
            foreach (String field in header)
            {
                table.AddHeaderCell(field);
            }
            Cell cell;

            foreach (IList <String> record in resultSet)
            {
                cell = new Cell();
                FileInfo file = new FileInfo(String.Format("../../../resources/img/{0}.jpg", record[0]));
                if (file.Exists)
                {
                    iText.Layout.Element.Image img = new Image(ImageDataFactory.Create(file.FullName));
                    img.SetAutoScaleWidth(true);
                    cell.Add(img);
                }
                else
                {
                    cell.Add(new Paragraph(record[0]));
                }
                table.AddCell(cell);
                table.AddCell(record[1]);
                table.AddCell(record[2]);
                table.AddCell(record[3]);
                table.AddCell(record[4]);
                table.AddCell(record[5]);
            }
            document.Add(table);
            document.Close();
        }
Esempio n. 11
0
        public virtual void CreatePdf(String dest)
        {
            PdfDocument pdf       = new PdfDocument(new PdfWriter(dest));
            Document    document  = new Document(pdf, PageSize.A4.Rotate());
            PdfCanvas   pdfCanvas = new PdfCanvas(pdf.AddNewPage());

            for (int i = 1; i <= 10; i++)
            {
                pdfCanvas.MoveTo(document.GetLeftMargin() + i * 50, 0);
                pdfCanvas.LineTo(document.GetLeftMargin() + i * 50, 595);
            }
            pdfCanvas.Stroke();
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            foreach (IList <String> record in resultSet)
            {
                Paragraph p = new Paragraph();
                p.Add(record[0].Trim()).Add(new Tab()).Add(record[1].Trim()).Add(new Tab()).Add(record[2].Trim()).Add(new
                                                                                                                      Tab()).Add(record[3].Trim()).Add(new Tab()).Add(record[4].Trim()).Add(new Tab()).Add(record[5].Trim());
                document.Add(p);
            }
            document.Close();
        }
Esempio n. 12
0
        public virtual void CreatePdf(String dest)
        {
            PdfDocument pdf      = new PdfDocument(new PdfWriter(dest));
            Document    document = new Document(pdf, PageSize.A4);

            float[]         stops    = new float[] { 70, 90, 420, 430, 520 };
            IList <TabStop> tabstops = new List <TabStop>();

            tabstops.Add(new TabStop(stops[0], TabAlignment.CENTER, new DottedLine()));
            tabstops.Add(new TabStop(stops[1], TabAlignment.LEFT));
            tabstops.Add(new TabStop(stops[2], TabAlignment.RIGHT, new SolidLine(0.5f)));
            tabstops.Add(new TabStop(stops[3], TabAlignment.LEFT));
            TabStop anchor = new TabStop(stops[4], TabAlignment.ANCHOR, new DashedLine());

            anchor.SetTabAnchor(' ');
            tabstops.Add(anchor);
            PdfCanvas pdfCanvas = new PdfCanvas(pdf.AddNewPage());

            for (int i = 0; i < stops.Length; i++)
            {
                pdfCanvas.MoveTo(document.GetLeftMargin() + stops[i], 0);
                pdfCanvas.LineTo(document.GetLeftMargin() + stops[i], 842);
            }
            pdfCanvas.Stroke();
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            foreach (IList <String> record in resultSet)
            {
                Paragraph p = new Paragraph();
                p.AddTabStops(tabstops);
                p.Add(record[0].Trim()).Add(new Tab()).Add(record[1].Trim()).Add(new Tab()).Add(record[2].Trim()).Add(new
                                                                                                                      Tab()).Add(record[3].Trim()).Add(new Tab()).Add(record[4].Trim()).Add(new Tab()).Add(record[5].Trim()
                                                                                                                                                                                                           + " \'");
                document.Add(p);
            }
            document.Close();
        }
        public virtual void CreatePdf(String dest)
        {
            PdfDocument pdf      = new PdfDocument(new PdfWriter(dest));
            Document    document = new Document(pdf, PageSize.A4.Rotate());

            float[]         stops    = new float[] { 40, 580, 590, 720 };
            IList <TabStop> tabstops = new List <TabStop>();

            tabstops.Add(new TabStop(stops[0], TabAlignment.LEFT));
            tabstops.Add(new TabStop(stops[1], TabAlignment.RIGHT));
            tabstops.Add(new TabStop(stops[2], TabAlignment.LEFT));
            TabStop anchor = new TabStop(stops[3], TabAlignment.ANCHOR);

            anchor.SetTabAnchor(' ');
            tabstops.Add(anchor);
            PdfCanvas pdfCanvas = new PdfCanvas(pdf.AddNewPage());

            for (int i = 0; i < stops.Length; i++)
            {
                pdfCanvas.MoveTo(document.GetLeftMargin() + stops[i], 0);
                pdfCanvas.LineTo(document.GetLeftMargin() + stops[i], 595);
            }
            pdfCanvas.Stroke();
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            foreach (IList <String> record in resultSet)
            {
                Paragraph p = new Paragraph();
                p.AddTabStops(tabstops);
                PdfAction uri  = PdfAction.CreateURI(String.Format("http://www.imdb.com/title/tt{0}", record[0]));
                Link      link = new Link(record[2].Trim(), uri);
                p.Add(record[1].Trim()).Add(new Tab()).Add(link).Add(new Tab()).Add(record[3].Trim()).Add(new Tab()).Add(record
                                                                                                                         [4].Trim()).Add(new Tab()).Add(record[5].Trim() + " \'");
                document.Add(p);
            }
            document.Close();
        }