public IActionResult PrintajOtpremnicu(int OtpremnicaId, int KupacId) { OtpremnicaReportVM Model = new OtpremnicaReportVM(); Model._kupac = new Kupac(); Model._kupac = db.Kupci.Where(x => x.KupacID == KupacId).Include(x => x.Grad).FirstOrDefault(); Model._otpremnica = new Otpremnica(); Model._otpremnica = db.Otpremnica.Where(x => x.OtpremnicaID == OtpremnicaId).Include(x => x.Kupac).FirstOrDefault(); Model._listaStavki = new List <OtpremnicaProizvod>(); Model._listaStavki = db.OtpremnicaProizvod.Where(x => x.OtpremnicaID == OtpremnicaId).Include(x => x.Otpremnica).Include(x => x.Proizvod).ToList(); OtpremnicaReport novaOtpremnica = new OtpremnicaReport(); byte[] otpremnicaPdf = novaOtpremnica.PrepareReport(Model); return(File(otpremnicaPdf, "application/pdf")); }
public byte[] PrepareReport(OtpremnicaReportVM otpremnicaPodaci) { _otpremnicaPodaci = otpremnicaPodaci; _document = new Document(PageSize.A4, 0f, 0f, 0f, 0f); _document.SetPageSize(PageSize.A4); _document.SetMargins(20f, 20f, 20f, 20f); _pdfTable.WidthPercentage = 100; _pdfTable.HorizontalAlignment = Element.ALIGN_LEFT; _fontStyle = FontFactory.GetFont("Tahoma", 8f, 1); PdfWriter.GetInstance(_document, _memoryStream); _document.Open(); _pdfTable.SetWidths(new float[] { 10f, 50f, 50f }); this.ReportHeader(); this.ReportBody(); _pdfTable.HeaderRows = 2; _document.Add(_pdfTable); _document.Close(); return(_memoryStream.ToArray()); }