private byte[] CreatePdf(PDFRaportInputModel inputModel) { using (var memoryStream = new MemoryStream()) { PdfWriter writer = new PdfWriter(memoryStream); PdfDocument pdfDoc = new PdfDocument(writer); Document document = new Document(pdfDoc); document.Add(_pdfService.AddTextToPdf()); document.Add(_pdfService.AddTableToPdf(inputModel.ItemList)); document.Close(); return(memoryStream.ToArray()); } }
public async Task <FileResult> CreatePdf() { var client = new PdfClient(); client.SetUrl("http://localhost:55892/api/PDFGeneration"); var inputModel = new PDFRaportInputModel(); inputModel.ItemList = new List <ItemModel>(); Mapper.Map(_itemService.GetAllItems(), inputModel.ItemList); var file = await client.PostWithFile(inputModel); return(File(file, "application/pdf")); }
public HttpResponseMessage Post(PDFRaportInputModel model) { var file = CreatePdf(model); return(Request.CreateResponse(HttpStatusCode.OK, file)); }