/// <summary> /// Encaspulated multi export as stream for downloading /// </summary> /// <param name="pack">pack containing elements to export and arguments to specify the format</param> /// <returns>Stream to offer as download</returns> public BufferedStream ExportAllAsStream(Interfaces.IExportablePack <Competentie> pack) { MemoryStream ms = new MemoryStream(); ExportAll(pack).Save(ms, false); byte[] bytes = ms.ToArray(); ms.Write(bytes, 0, bytes.Length); ms.Position = 0; return(new BufferedStream(ms)); }
/// <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(Interfaces.IExportablePack <Competentie> pack) { Document prePdf = new Document(); //Document markup DefineStyles(prePdf); BuildCover(prePdf, "Competentie-Overzicht voor Informatica"); DefineTableOfContents(prePdf, pack.ToExport); //Here starts the real exporting CompetentieExporterFactory cef = new CompetentieExporterFactory(); competentieExporterStrategy = cef.GetStrategy(pack.Options as CompetentieExportArguments); foreach (DomainDAL.Competentie c in pack.ToExport) { Section sect = prePdf.AddSection(); try { sect = competentieExporterStrategy.Export(c, sect); } catch (Exception e) { sect.AddParagraph("An error has occured while invoking an export-function on Competentie: " + c.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); }