public FileStream Create() { string filePath = DEST + "Receipt_" + Date.ToString("yyyyMMddHHmmss") + ".pdf"; ConverterProperties properties = new ConverterProperties(); properties.SetBaseUri(BASEURI); var file = new FileStream(SRC, FileMode.Open); string fileContents; using (StreamReader reader = new StreamReader(file)) { fileContents = reader.ReadToEnd(); } fileContents = fileContents.Replace("{{fullReceiptNumber}}", PointOfSaleNumber + "-" + ReceiptNumber); fileContents = fileContents.Replace("{{date}}", Date.ToString("dd/MM/yyyy")); fileContents = fileContents.Replace("{{customerFullName}}", CustomerFullName); fileContents = fileContents.Replace("{{totalAmount}}", ReceiptConcepts.Sum(x => x.Amount).ToString()); fileContents = fileContents.Replace("{{concepts}}", GetConceptsRows()); HtmlConverter.ConvertToPdf(fileContents, new FileStream(filePath, FileMode.Create), properties); var finalFile = new FileStream(filePath, FileMode.Open); return(finalFile); }
private string GetConceptsRows() { var concepts = string.Empty; ReceiptConcepts.ForEach(x => concepts += CreateConceptRow(x)); return(concepts); }