/// <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(DomainDAL.Module toExport) { Document prePdf = new Document(); //Document markup DefineStyles(prePdf); BuildCover(prePdf, toExport.Naam + "\n" + toExport.CursusCode); //Here starts the real exporting Section sect = prePdf.AddSection(); ModuleExportArguments opt = new ModuleExportArguments() { ExportAll = true }; ModuleExporterFactory mef = new ModuleExporterFactory(); moduleExporterStrategy = mef.GetStrategy(opt); try { sect = moduleExporterStrategy.Export(toExport, sect); } catch (Exception e) { sect.AddParagraph("An error has occured while invoking an export-function on Module: " + toExport.Naam + "\n" + e.Message, "error"); } PdfDocumentRenderer rend = new PdfDocumentRenderer(false, PdfFontEmbedding.Always); rend.Document = prePdf; rend.RenderDocument(); return(rend.PdfDocument); }
/// <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 <DomainDAL.Module> pack) { Document prePdf = new Document(); //Document markup DefineStyles(prePdf); BuildCover(prePdf, "Module-Overzicht voor Informatica"); DefineTableOfContents(prePdf, pack.ToExport); //Here starts the real exporting ModuleExporterFactory mef = new ModuleExporterFactory(); moduleExporterStrategy = mef.GetStrategy(pack.Options as ModuleExportArguments); foreach (DomainDAL.Module m in pack.ToExport) { Section sect = prePdf.AddSection(); try { sect = moduleExporterStrategy.Export(m, sect); } catch (Exception e) { sect.AddParagraph("An error has occured while invoking an export-function on Module: " + m.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); }