Example #1
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);
        }
Example #2
0
        // ---------------------------------------------------------------------------

        /**
         * Creates a Phrase containing information about a movie.
         * @param    movie    the movie for which you want to create a Paragraph
         */
        public Phrase CreateMovieInformation(Movie movie)
        {
            Phrase p = new Phrase();

            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(new Chunk("Year: ", FilmFonts.BOLDITALIC));
            p.Add(new Chunk(movie.Year.ToString(), FilmFonts.NORMAL));
            p.Add(new Chunk(" Duration: ", FilmFonts.BOLDITALIC));
            p.Add(new Chunk(movie.Duration.ToString(), FilmFonts.NORMAL));
            p.Add(new Chunk(" minutes", FilmFonts.NORMAL));
            p.Add(new LineSeparator(0.3f, 100, null, Element.ALIGN_CENTER, -2));
            return(p);
        }
Example #3
0
// ===========================================================================
        public override void Write(Stream stream)
        {
            // step 1
            using (Document document = new Document()) {
                // step 2
                PdfWriter.GetInstance(document, stream);
                // step 3
                document.Open();
                // step 4
                IEnumerable <Movie> movies = PojoFactory.GetMovies();
                foreach (Movie movie in movies)
                {
                    // Create a paragraph with the title
                    Paragraph title = new Paragraph(
                        PojoToElementFactory.GetMovieTitlePhrase(movie)
                        );
                    title.Alignment = Element.ALIGN_LEFT;
                    document.Add(title);
                    // Add the original title next to it using a dirty hack
                    if (!string.IsNullOrEmpty(movie.OriginalTitle))
                    {
                        Paragraph dummy = new Paragraph("\u00a0", FilmFonts.NORMAL);
                        dummy.Leading = -18;
                        document.Add(dummy);
                        Paragraph originalTitle = new Paragraph(
                            PojoToElementFactory.GetOriginalTitlePhrase(movie)
                            );
                        originalTitle.Alignment = Element.ALIGN_RIGHT;
                        document.Add(originalTitle);
                    }
                    // Info about the director
                    float indent = 20;
                    // Loop over the directors
                    foreach (Director pojo in movie.Directors)
                    {
                        Paragraph director = new Paragraph(
                            PojoToElementFactory.GetDirectorPhrase(pojo)
                            );
                        director.IndentationLeft = indent;
                        document.Add(director);
                        indent += 20;
                    }
                    // Info about the country
                    indent = 20;
                    // Loop over the countries
                    foreach (Country pojo in movie.Countries)
                    {
                        Paragraph country = new Paragraph(
                            PojoToElementFactory.GetCountryPhrase(pojo)
                            );
                        country.Alignment        = Element.ALIGN_RIGHT;
                        country.IndentationRight = indent;
                        document.Add(country);
                        indent += 20;
                    }
                    // Extra info about the movie
                    Paragraph info = CreateYearAndDuration(movie);
                    info.Alignment    = Element.ALIGN_CENTER;
                    info.SpacingAfter = 36;
                    document.Add(info);
                }
            }
        }