Example #1
0
        private static void Emit(Document document, PdfContentByte content, List <FilmDetails> films, string runName)
        {
            int count = 0;

            while (count < films.Count)
            {
                NamePlateGenerator.LayoutPage(content, Enumerable.ToList <FilmDetails>(Enumerable.Take <FilmDetails>(Enumerable.Skip <FilmDetails>((IEnumerable <FilmDetails>)films, count), 10)), runName);
                if (count + 10 < films.Count)
                {
                    document.NewPage();
                }
                count += 10;
            }
        }
Example #2
0
        public void Execute(IList <FilmDetails> films)
        {
            using (List <string> .Enumerator enumerator = Enumerable.ToList <string>(Enumerable.Distinct <string>(Enumerable.Select <FilmDetails, string>((IEnumerable <FilmDetails>)films, (Func <FilmDetails, string>)(f => f.Genre)))).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    string genre = enumerator.Current;
                    if (!string.IsNullOrEmpty(genre))
                    {
                        Document  document = new Document(PageSize.A4);
                        PdfWriter instance = PdfWriter.GetInstance(document, (Stream)File.Open(this.OutputFilePath + genre.Trim() + ".pdf", FileMode.Create, FileAccess.Write));
                        document.Open();
                        PdfContentByte directContent = instance.DirectContent;
                        NamePlateGenerator.Emit(document, directContent, Enumerable.ToList <FilmDetails>(Enumerable.Where <FilmDetails>((IEnumerable <FilmDetails>)films, (Func <FilmDetails, bool>)(f => f.Genre == genre))), "A");
                        document.NewPage();
                        NamePlateGenerator.Emit(document, directContent, Enumerable.ToList <FilmDetails>(Enumerable.Where <FilmDetails>((IEnumerable <FilmDetails>)films, (Func <FilmDetails, bool>)(f => f.Genre == genre))), "B");
                        document.NewPage();
                        NamePlateGenerator.Emit(document, directContent, Enumerable.ToList <FilmDetails>(Enumerable.Where <FilmDetails>((IEnumerable <FilmDetails>)films, (Func <FilmDetails, bool>)(f => f.Genre == genre))), "C");
                        document.NewPage();
                        NamePlateGenerator.Emit(document, directContent, Enumerable.ToList <FilmDetails>(Enumerable.Where <FilmDetails>((IEnumerable <FilmDetails>)films, (Func <FilmDetails, bool>)(f => f.Genre == genre))), "D");
                        document.NewPage();
                        NamePlateGenerator.Emit(document, directContent, Enumerable.ToList <FilmDetails>(Enumerable.Where <FilmDetails>((IEnumerable <FilmDetails>)films, (Func <FilmDetails, bool>)(f => f.Genre == genre))), "E");
                        document.NewPage();
                        NamePlateGenerator.Emit(document, directContent, Enumerable.ToList <FilmDetails>(Enumerable.Where <FilmDetails>((IEnumerable <FilmDetails>)films, (Func <FilmDetails, bool>)(f => f.Genre == genre))), "F");
                        document.NewPage();
                        NamePlateGenerator.Emit(document, directContent, Enumerable.ToList <FilmDetails>(Enumerable.Where <FilmDetails>((IEnumerable <FilmDetails>)films, (Func <FilmDetails, bool>)(f => f.Genre == genre))), "G");
                        document.NewPage();
                        NamePlateGenerator.Emit(document, directContent, Enumerable.ToList <FilmDetails>(Enumerable.Where <FilmDetails>((IEnumerable <FilmDetails>)films, (Func <FilmDetails, bool>)(f => f.Genre == genre))), "H");
                        document.NewPage();
                        document.Close();
                    }
                }
            }
            List <FilmDetails> films1 = new List <FilmDetails>()
            {
                new FilmDetails()
                {
                    Title   = "Intermission",
                    RunTime = 15
                },
                new FilmDetails()
                {
                    Title   = "Short TBC",
                    RunTime = 15
                },
                new FilmDetails()
                {
                    Title   = "Film maker present",
                    RunTime = 30
                },
                new FilmDetails()
                {
                    Title   = "Film maker present",
                    RunTime = 40
                },
                new FilmDetails()
                {
                    Title   = "Intermission",
                    RunTime = 15
                },
                new FilmDetails()
                {
                    Title   = "Short TBC",
                    RunTime = 15
                },
                new FilmDetails()
                {
                    Title   = "Film maker present",
                    RunTime = 30
                },
                new FilmDetails()
                {
                    Title   = "Film maker present",
                    RunTime = 40
                }
            };
            Document  document1 = new Document(PageSize.A4);
            PdfWriter instance1 = PdfWriter.GetInstance(document1, (Stream)File.Open(this.OutputFilePath + "Extras.pdf", FileMode.Create, FileAccess.Write));

            document1.Open();
            PdfContentByte directContent1 = instance1.DirectContent;

            for (int index = 0; index < 5; ++index)
            {
                NamePlateGenerator.Emit(document1, directContent1, films1, string.Empty);
                document1.NewPage();
            }
            document1.Close();
        }