/** * Creates a temporary context to a IDocumentGenerator and writes * the result to disk. */ public void EmitDocument(IDocumentGenerator generator, string uri = null) { var context = GetContext(uri); var result = generator.Generate(context); SavePage(result, uri); }
public HttpResponseMessage GeneratePdfFromHtml([FromBody] GenerateDocumentRequest request) { request.ValidateNotNull(); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(_documentGenerator.Generate(request.Content, request.Filename, DocumentTypeEnum.Html, DocumentTypeEnum.Pdf, null).ByteContent) }; response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf"); response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = request.Filename + ".pdf" }; return(response); }
public GeneratedDocumentDomain ExportTemplate(int templateVersionId, DocumentTypeEnum outputDocType) { TemplateVersionDomain templateVersionDomain = _templateVersionManipulation.GetByVersionId(templateVersionId); if (templateVersionDomain == null) { throw new NsiArgumentNullException(TemplateManagementMessages.TemplateVersionInvalidId); } string name = _templateManipulation.GetTemplateNameById(templateVersionDomain.TemplateId); GeneratedDocumentDomain generatedDocumentDomain = _documentGenerator.Generate(templateVersionDomain.Content, name, DocumentTypeEnum.Json, outputDocType, templateVersionId); return(generatedDocumentDomain); }
public void GenerateDocument_TypeIsNull() { // Input and output type are null documentGenerator.Generate("Test", "Test", null, null, null); }