Esempio n. 1
0
 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"));
        }
Esempio n. 3
0
        public HttpResponseMessage Post(PDFRaportInputModel model)
        {
            var file = CreatePdf(model);

            return(Request.CreateResponse(HttpStatusCode.OK, file));
        }