Ejemplo n.º 1
0
// ---------------------------------------------------------------------------    
    public override void Write(Stream stream) {
      using (ZipFile zip = new ZipFile()) {
        HtmlMovies2 movies = new HtmlMovies2();
        // create a StyleSheet
        StyleSheet styles = new StyleSheet();
        styles.LoadTagStyle("ul", "indent", "10");
        styles.LoadTagStyle("li", "leading", "14");
        styles.LoadStyle("country", "i", "");
        styles.LoadStyle("country", "color", "#008080");
        styles.LoadStyle("director", "b", "");
        styles.LoadStyle("director", "color", "midnightblue");
        movies.SetStyles(styles);
        // create extra properties
        Dictionary<String,Object> map = new Dictionary<String, Object>();
        map.Add(HTMLWorker.FONT_PROVIDER, new MyFontFactory());
        map.Add(HTMLWorker.IMG_PROVIDER, new MyImageFactory());
        movies.SetProviders(map);
        // creates HTML and PDF (reusing a method from the super class)
        byte[] pdf = movies.CreateHtmlAndPdf(stream);
        zip.AddEntry(HTML, movies.Html.ToString());
        zip.AddEntry(RESULT1, pdf);
        zip.AddEntry(RESULT2, movies.CreatePdf());
        // add the images so the static html file works
        foreach (Movie movie in PojoFactory.GetMovies()) {
          zip.AddFile(
            Path.Combine(
              Utility.ResourcePosters, 
              string.Format("{0}.jpg", movie.Imdb)
            ), 
            ""
          );
        }
        zip.Save(stream);             
      }
    }
Ejemplo n.º 2
0
// ---------------------------------------------------------------------------
        public override void Write(Stream stream)
        {
            using (ZipFile zip = new ZipFile()) {
                HtmlMovies2 movies = new HtmlMovies2();
                // create a StyleSheet
                StyleSheet styles = new StyleSheet();
                styles.LoadTagStyle("ul", "indent", "10");
                styles.LoadTagStyle("li", "leading", "14");
                styles.LoadStyle("country", "i", "");
                styles.LoadStyle("country", "color", "#008080");
                styles.LoadStyle("director", "b", "");
                styles.LoadStyle("director", "color", "midnightblue");
                movies.SetStyles(styles);
                // create extra properties
                Dictionary <String, Object> map = new Dictionary <String, Object>();
                map.Add(HTMLWorker.FONT_PROVIDER, new MyFontFactory());
                map.Add(HTMLWorker.IMG_PROVIDER, new MyImageFactory());
                movies.SetProviders(map);
                // creates HTML and PDF (reusing a method from the super class)
                byte[] pdf = movies.CreateHtmlAndPdf(stream);
                zip.AddEntry(HTML, movies.Html.ToString());
                zip.AddEntry(RESULT1, pdf);
                zip.AddEntry(RESULT2, movies.CreatePdf());
                // add the images so the static html file works
                foreach (Movie movie in PojoFactory.GetMovies())
                {
                    zip.AddFile(
                        Path.Combine(
                            Utility.ResourcePosters,
                            string.Format("{0}.jpg", movie.Imdb)
                            ),
                        ""
                        );
                }
                zip.Save(stream);
            }
        }