public async Task PrintPackagingSlipsToPdf(Stream stream, IList <Shipment> shipments, string languageId = "") { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } if (shipments == null) { throw new ArgumentNullException(nameof(shipments)); } var lang = await _languageService.GetLanguageById(languageId); if (lang == null) { throw new ArgumentException(string.Format("Cannot load language. ID={0}", languageId)); } _generatePdf.SetConvertOptions(new ConvertOptions() { PageSize = Wkhtmltopdf.NetCore.Options.Size.A4, PageMargins = new Wkhtmltopdf.NetCore.Options.Margins() { Bottom = 10, Left = 10, Right = 10, Top = 10 }, FooterHtml = CommonPath.WebMapPath(_shipmentFooter) }); var html = await _viewRenderService.RenderToStringAsync <IList <Shipment> >(_shipmentsTemaplate, shipments); var pdfBytes = _generatePdf.GetPDF(html); stream.Write(pdfBytes); }
public async Task PrintOrdersToPdf(Stream stream, IList <Order> orders, string languageId = "", string vendorId = "") { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } if (orders == null) { throw new ArgumentNullException(nameof(orders)); } _generatePdf.SetConvertOptions(new ConvertOptions() { PageSize = Wkhtmltopdf.NetCore.Options.Size.A4, PageMargins = new Wkhtmltopdf.NetCore.Options.Margins() { Bottom = 10, Left = 10, Right = 10, Top = 10 }, FooterHtml = CommonPath.WebMapPath(_orderFooter) }); var html = await _viewRenderService.RenderToStringAsync <(IList <Order>, string)>(_orderTemaplate, new (orders, vendorId)); var pdfBytes = _generatePdf.GetPDF(html); stream.Write(pdfBytes); }
public virtual void PrepareFlagsModel(LanguageModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } model.FlagFileNames = Directory .EnumerateFiles(CommonPath.WebMapPath("/assets/images/flags/"), "*.png", SearchOption.TopDirectoryOnly) .Select(Path.GetFileName) .ToList(); }
public async Task <string> PrintOrderToPdf(Order order, string languageId, string vendorId = "") { if (order == null) { throw new ArgumentNullException(nameof(order)); } var fileName = string.Format("order_{0}_{1}.pdf", order.OrderGuid, CommonHelper.GenerateRandomDigitCode(4)); var filePath = Path.Combine(CommonPath.WebMapPath("assets/files/exportimport"), fileName); using (var fileStream = new FileStream(filePath, FileMode.Create)) { var orders = new List <Order> { order }; await PrintOrdersToPdf(fileStream, orders, languageId, vendorId); } return(filePath); }