Beispiel #1
0
        /// <summary>
        /// Basic export function to generate PDF from one element
        /// </summary>
        /// <param name="toExport">element to export</param>
        /// <returns>A PDF Document</returns>
        public PdfDocument Export(Leerlijn toExport)
        {
            Document prePdf = new Document();

            //Document markup
            DefineStyles(prePdf);
            BuildCover(prePdf, "Leerlijn: " + toExport.Naam);

            //Here starts the real exporting
            Section sect = prePdf.AddSection();

            LeerlijnExportArguments opt = new LeerlijnExportArguments()
            {
                ExportAll = true
            };

            LeerlijnExporterFactory lef = new LeerlijnExporterFactory();

            leerlijnExporterStrategy = lef.GetStrategy(opt);

            try
            {
                sect = leerlijnExporterStrategy.Export(toExport, sect);
            }
            catch (Exception e)
            {
                sect.AddParagraph("An error has occured while invoking an export-function on Leerlijn: " + toExport.Naam + "\n" + e.Message, "error");
            }

            PdfDocumentRenderer rend = new PdfDocumentRenderer(false, PdfFontEmbedding.Always);

            rend.Document = prePdf;
            rend.RenderDocument();
            return(rend.PdfDocument);
        }
Beispiel #2
0
        /// <summary>
        /// Basic export function to generate PDF from a list of elements
        /// </summary>
        /// <param name="pack">pack containing elements to export and arguments to specify the format</param>
        /// <returns>A PDF Document</returns>
        public PdfDocument ExportAll(IExportablePack <Leerlijn> pack)
        {
            Document prePdf = new Document();

            //Document markup
            DefineStyles(prePdf);
            BuildCover(prePdf, "Leerlijn-Overzicht voor Informatica");
            DefineTableOfContents(prePdf, pack.ToExport);

            //Here starts the real exporting

            LeerlijnExporterFactory lef = new LeerlijnExporterFactory();

            leerlijnExporterStrategy = lef.GetStrategy(pack.Options as LeerlijnExportArguments);

            foreach (DomainDAL.Leerlijn l in pack.ToExport)
            {
                Section sect = prePdf.AddSection();
                try
                {
                    sect = leerlijnExporterStrategy.Export(l, sect);
                }
                catch (Exception e)
                {
                    sect.AddParagraph("An error has occured while invoking an export-function on Leerlijn: " + l.Naam + "\n" + e.Message, "error");
                }

                //Page numbers (only for multi-export)
                Paragraph p = new Paragraph();
                p.AddPageField();
                sect.Footers.Primary.Add(p);
                sect.Footers.EvenPage.Add(p.Clone());
            }

            PdfDocumentRenderer rend = new PdfDocumentRenderer(false, PdfFontEmbedding.Always);

            rend.Document = prePdf;
            rend.RenderDocument();
            return(rend.PdfDocument);
        }