public async Task <ResponseTOCContractDTO> GenerateDocumentTOC(InvestorInfo investorInfo) { if (investorInfo == null) { throw new ArgumentNullException(nameof(investorInfo)); } GeneratePDF generatePDF = new GeneratePDF(); string newDocumentFileName = generatePDF.GenerateInvestorDocument(investorInfo); ResponseTOCContractDTO response = new ResponseTOCContractDTO(); if (!string.IsNullOrWhiteSpace(newDocumentFileName)) { ContractInvestor contractInvestor = new ContractInvestor() { FileName = newDocumentFileName, Email = investorInfo.Email, FullName = string.Concat(investorInfo.FirstName, " ", investorInfo.LastName), DocNumber = investorInfo.DocumentNumber }; response = await _tocLogic.CreateContract(contractInvestor); } return(response); }
public async Task <IActionResult> GeneratePdfEmployeeExpense(string UserName, string MonthYear) { PDFViewModel pdfVM; try { //Get PDF HTML var getPdfHtml = await _unitOfWork.AdminDashboard.GetEmployeeExpenseForPDF(UserName, MonthYear); //Set FileName string fileName = $"{UserName}_{ MonthYear}_{DateTime.Now.ToString("ddmmyyyy")}{DateTime.Now.Millisecond}.pdf"; //Generate PDF GeneratePDF generatePDF = new GeneratePDF(_converter, _host); byte[] file = generatePDF.GetPdfFile(fileName, getPdfHtml, "PDF Report", "For PSR", "Signature of PSR"); string fullfilePath = Path.Combine(_host.WebRootPath, "Downloads", fileName); pdfVM = new PDFViewModel() { File = file.ToArray(), FileName = fileName }; } catch (Exception Ex) { throw Ex; } return(Ok(pdfVM)); }
public IHttpActionResult Generate([FromUri]string format) { IGenerate generator = null; byte[] content; switch (format) { case "pdf": { generator = new GeneratePDF(); break; } default: return ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Invalid format")); } List<food> foods = _db.food.ToList(); content = generator.Generate(foods); string pdfName = "Foods"; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = "application/" + format; HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + pdfName + "." + format); HttpContext.Current.Response.ContentType = "application/" + format; HttpContext.Current.Response.Buffer = true; HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); HttpContext.Current.Response.BinaryWrite(content); HttpContext.Current.Response.End(); HttpContext.Current.Response.Close(); return Ok(); }
public FileResult LoadPDF(int applicationId) { Application application = _repository.Applications .FirstOrDefault(app => app.ApplicationId == applicationId); var pdf = GeneratePDF.ByApplication(application, application.Enrollee); return(File(pdf, "application/pdf", "Application" + application.Enrollee.LastName + ".pdf")); }
protected void ButtonGeneratePDF_Click(object sender, EventArgs e) { var reportGenerator = new GeneratePDF(); reportGenerator.GenerateReport(HttpContext.Current.Server.MapPath("~/Common/PDFReports/")); Response.Redirect("Cyclists.aspx"); }
public ActionResult Index() { ViewBag.Title = "Home Page"; GeneratePDF pdf = new GeneratePDF(); pdf.ManipulatePdf("C:\\Users\\Norman\\Documents\\pdf\\simple_table.pdf"); return(View()); }
private void Print_Click(object sender, RoutedEventArgs e) { var month = calendars[TabsMain.SelectedIndex].DisplayStartDate.Month; var year = calendars[TabsMain.SelectedIndex].DisplayStartDate.Year; var pdf = new GeneratePDF(); using (var db = new PodaciContext()) pdf.Create(month, year, models[TabsMain.SelectedIndex].CleanerId, db); }
protected void btnSavePDFForm2_Click(object sender, EventArgs e) { string headerDetail = invoiceHeaderDetails.Value; string tableContent = "[" + HdnValue.Value + "]"; string hdnRemarksData = hdnRemarks.Value; string isMultipleShipping = hdnIsMultipleShipping.Value; string templateFolderPath = TemplateName; GeneratePDF gpdf = new GeneratePDF(); gpdf.GenerateInvoicePDF(headerDetail, tableContent, hdnRemarksData, isMultipleShipping, templateFolderPath, GetStoreID, GetPortalID, GetCurrentCultureName); }
private void SellButton_Click(object sender, EventArgs e) { this.book = userInteract.getBook(titleBox.Text, authorBox.Text, user); if (userInteract.existsBook(this.book)) { if (!quantityBox.Text.Equals("")) { if (Int32.Parse(quantityBox.Text) <= book.quantity) { book.addObserver(user); userInteract.sellBook(book, Int32.Parse(quantityBox.Text)); if (Int32.Parse(quantityBox.Text) == book.quantity) { GeneratePDF generatePDF = new GeneratePDF(); GenerateCSV generateCSV = new GenerateCSV(); String text = "Title: " + book.title + "\n" + "Author: " + book.author + "\n" + "Genre: " + book.genre; String filename = book.author + "-" + book.title; generatePDF.createPDF(filename, text); generateCSV.addNeededBook(book.title, book.author); MessageBox.Show("There are no more books with: \n" + "Title: " + book.title + "\n" + "Author: " + book.author); } MessageBox.Show("Selled " + quantityBox.Text + " books: \n" + "Title: " + titleBox.Text + "\n" + "Author: " + authorBox.Text + "\n" + "Total price: " + totalLabel.Text); this.Close(); } else { MessageBox.Show("Insufficient stock!"); } } else { MessageBox.Show("Please fill the Quantity field!"); } } else { MessageBox.Show("This book doesn't exist!"); } }
public int GetClientes(String id, String id2, string id3, string id4) { //id=email //id2=cliente //id3=es email? //id4=sucursal int res = 0; using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["promovil_rest.Properties.Settings.Conexion"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand("sp_select_estado_cuenta", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@cliente", SqlDbType.VarChar).Value = id2.ToString(); cmd.Parameters.Add("@sucursal", SqlDbType.VarChar).Value = id4.ToString(); if (con.State != ConnectionState.Open) { con.Open(); } SqlDataAdapter adp = new SqlDataAdapter(); adp.TableMappings.Add("Table", "cuentas"); adp.SelectCommand = cmd; adp.Fill(ds); if (con.State == ConnectionState.Open) { con.Close(); } } } if (ds.Tables[0].Rows.Count > 0) { if (id3 == "1") { string fecha = DateTime.Now.ToString("yyyy-MM-dd"); list = datasetToJson(ds); string cliente = list[0].Cliente.ToString(); pdf = new GeneratePDF(); string path = "C:\\Estados de cuenta\\" + cliente + fecha + ".pdf"; // string path = "C:\\Users\\Norman\\Documents\\Cotizaciones\\" + cliente + fecha + ".pdf"; pdf.ManipulatePdf(path, list); email(BODY + fecha, path, id, cliente); } res = 1; } return(res); }
private static MemoryStream BuildPenaltyPDF(Penalty permit) { var machineInfo = "test"; var shiftInfo = "file"; var oDoc = GeneratePDF.CreatePDFPermitApplication("Penalty", "Inf Owner"); var oMem = new MemoryStream(); var oWriter = GeneratePDF.CreatePdfWriter(oDoc, oMem); oWriter.PageEvent = new PDFPageEvent(machineInfo, shiftInfo); oDoc.Open(); oDoc.Close(); oMem.Close(); return(oMem); }
private void PdfButton_Click(object sender, EventArgs e) { GeneratePDF pdf = new GeneratePDF(); foreach (DataGridViewRow row in OrdersGridView.SelectedRows) { string ordernr = row.Cells[0].Value.ToString(); string client = row.Cells[4].Value.ToString(); string adres1 = row.Cells[6].Value.ToString() + " " + row.Cells[5].Value.ToString(); string adres2 = row.Cells[7].Value.ToString() + ", " + row.Cells[8].Value.ToString(); pdf.ExportPDF(ordernr, adres1, adres2, client, (Company)CompanyID.SelectedItem, 456, "uwagi"); } MessageBox.Show("Wygenerowano pdf"); }
protected void btnSavePDFForm2_Click(object sender, EventArgs e) { try { string tableContent = "[" + HdnValue.Value + "]"; string hiddenValue = hdnDescriptionValue.Value; string templateFolderPath = TemplateName; GeneratePDF gPdf = new GeneratePDF(); gPdf.GenerateOrderDetailsPDF(tableContent, hiddenValue, templateFolderPath); } catch (Exception ex) { ProcessException(ex); } }
//Generar PDF public ActionResult GenerarPDF() { GeneratePDF oGenerar = new GeneratePDF(); List <EntityDetallePedido> oListDetallePedido = (List <EntityDetallePedido>)Session["ListDetallePedido"]; if (null == Session["ListDetallePedido"]) { oListDetallePedido = new List <EntityDetallePedido>(); } try { oGenerar.CreatePDF("VistaPreviaPDF", "VPPDF", oListDetallePedido.ToList(), Response); } catch (Exception) { } return(null); }
public IActionResult GenerateDocumentKeyNUA(ContractInfo contractInfo) { if (contractInfo == null) { throw new ArgumentNullException(nameof(contractInfo)); } GeneratePDF generatePDF = new GeneratePDF(); string newDocumentFileName = generatePDF.GenerateInvestorDocument(contractInfo); if (string.IsNullOrWhiteSpace(newDocumentFileName)) { return(BadRequest("Un error ocurrió al crear el archivo.")); } return(Ok(newDocumentFileName)); }
protected void btnSavePDFForm2_Click(object sender, EventArgs e) { try { string strTableContent = HttpUtility.HtmlDecode(HdnValue.Value); strTableContent = strTableContent.Trim().Replace("[\"", "").Replace("\\\"", "\"").Replace("}\",\"", "},").Replace("\"]", ""); string strHiddenValue = HttpUtility.HtmlDecode(hdnDescriptionValue.Value); strHiddenValue = strHiddenValue.Trim().Replace("[\"", "[").Replace("\\\"", "\"").Replace("}\",\"", "},").Replace("\"]", "]").Replace("\"{", "{").Replace("}\"", "}"); string tableContent = "[" + strTableContent + "]"; string hiddenValue = strHiddenValue; string templateFolderPath = TemplateName; GeneratePDF gPdf = new GeneratePDF(); gPdf.GenerateOrderDetailsPDF(tableContent, hiddenValue, templateFolderPath, GetStoreID, GetPortalID, GetCurrentCultureName); } catch (Exception ex) { ProcessException(ex); } }
public HttpResponseMessage GenereteFile(GeneratePDF GenFile) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest); byte[] buffer = (byte[])GenFile.Generate(); var contentLength = buffer.Length; var statuscode = HttpStatusCode.OK; response = Request.CreateResponse(statuscode); response.Content = new StreamContent(new MemoryStream(buffer)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf"); response.Content.Headers.ContentLength = contentLength; ContentDispositionHeaderValue contentDisposition = null; string RandomeFile = Guid.NewGuid().ToString(); if (ContentDispositionHeaderValue.TryParse("inline; filename=" + RandomeFile + ".pdf", out contentDisposition)) { response.Content.Headers.ContentDisposition = contentDisposition; } return(response); }
private void CreateLabel() { try { AddressInfo addInfo = (AddressInfo)Session["sl_toAddress"]; AddressInfo billAddInfo = (AddressInfo)Session["sl_frAddress"]; AspxCommerce.Core.WareHouseAddress whaInfo = GetWareHouseAddress(GetStoreID, GetPortalID); _itemslist = new List <ItemDetail>(); _itemslist = (List <ItemDetail>)Session["sl_items"]; GeneratePDF.BasicPackageInfo basciPagIngo = new GeneratePDF.BasicPackageInfo(); basciPagIngo.TrackingNo = ""; basciPagIngo.TotalWeight = Convert.ToDecimal(lblPackageTotalWeight.Text); basciPagIngo.WeightUnit = lblStoreWeightUnit.Text; basciPagIngo.WaterMark = ""; basciPagIngo.BarcodeNo = ""; basciPagIngo.SenderName = billAddInfo.FirstName + " " + billAddInfo.LastName; basciPagIngo.CautionMessage = "Handle With Care."; basciPagIngo.ServiceType = lblUserShippingMethod.Text; basciPagIngo.Length = Convert.ToInt32(txtPackageLength.Text); basciPagIngo.Width = Convert.ToInt32(txtPackageWidth.Text); basciPagIngo.Height = Convert.ToInt32(txtPackageHeight.Text); basciPagIngo.DimensionUnit = lblStoreDimensionUnit.Text; AspxCommonInfo aspxCommonObj = new AspxCommonInfo(); aspxCommonObj.StoreID = GetStoreID; aspxCommonObj.PortalID = GetPortalID; aspxCommonObj.UserName = GetUsername; aspxCommonObj.CultureName = GetCurrentCultureName; GeneratePDF gPdf = new GeneratePDF(); gPdf.CreateShipmentLabel(addInfo, whaInfo, aspxCommonObj, basciPagIngo); } catch (Exception ex) { throw ex; } }
public ActionResult MBLPDF(ParameterModel param) { var model = new MBL(); IList <OTHERCHARGE> list = new List <OTHERCHARGE>(); if (param.midx != 0) { model = blService.getMBL(param); list = model.OTHERCHARGE.ToList(); GeneratePDF PDF = new GeneratePDF(model, list); PDF.sourcePdfPath = Server.MapPath(ConfigurationManager.AppSettings["SOURCE_PDF_PATH"]); PDF.savePdfPath = Server.MapPath(ConfigurationManager.AppSettings["SAVE_PDF_PATH"]); PDF.GenerateMBLPDF(); JsonResult result = new JsonResult(); JsonObject jsonObject = new JsonObject(); jsonObject.SmallUrl = ConfigurationManager.AppSettings["SAVE_PDF_PATH"] + model.mblNo.Trim() + ".pdf"; jsonObject.isDesktop = true; result.Data = jsonObject; result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(result); } return(View()); }
public async Task <IActionResult> SendMail(EmailDTO emailDTO) { ServiceResponse <EmailDTO> Data = new ServiceResponse <EmailDTO>(); try { #region ConvertToPdf HtmlToPdf converter = new HtmlToPdf(); //create a new pdf document converting an url PdfDocument doc = converter.ConvertHtmlString(GeneratePDF.GetHtmlString(emailDTO)); //save pdf document byte[] pdf = doc.Save(); //close pdf document doc.Close(); #endregion #region Get AzureAd Config var scopeFactory = this.HttpContext.RequestServices.GetService <IServiceScopeFactory>(); using (var scope = scopeFactory.CreateScope()) { var serviceProvider = scope.ServiceProvider; var options = serviceProvider.GetRequiredService <AzureAdOptions>(); var optionsMail = serviceProvider.GetRequiredService <SendMailOptions>(); #endregion #region FileAttachment MessageAttachmentsCollectionPage attachments = new MessageAttachmentsCollectionPage(); attachments.Add(new FileAttachment { ODataType = "#microsoft.graph.fileAttachment", ContentBytes = pdf, ContentType = BodyType.Text.ToString(), ContentId = "Piecejointe", Name = optionsMail.FileName }); #endregion #region Message var message = new Message { Subject = optionsMail.Subject, Body = new ItemBody { ContentType = BodyType.Html, Content = "<div>Bonjour " + emailDTO.VisiteDTO.Client.Nom + " " + emailDTO.VisiteDTO.Client.Prenom + " </div> <br/> <br/><div>" + Environment.NewLine + optionsMail.Body + " </div>" }, ToRecipients = new List <Recipient>() { new Recipient { EmailAddress = new EmailAddress { Address = emailDTO.VisiteDTO.Client.Courriel } } } , Attachments = attachments }; #endregion #region confidentialClient IConfidentialClientApplication confidentialClient = ConfidentialClientApplicationBuilder .Create(options.ClientId) .WithClientSecret(options.ClientSecret) .WithAuthority(new Uri($"https://login.microsoftonline.com/{options.TenantId}/v2.0")) .Build(); #endregion #region obtient un nouveau jeton // Récupère un jeton d'accès pour Microsoft Graph (obtient un nouveau jeton si nécessaire). var authResult = await confidentialClient .AcquireTokenForClient(options.Scopes) .ExecuteAsync().ConfigureAwait(false); // Construise le client Microsoft Graph. En tant que fournisseur d'authentification, définissez un asynchrone // qui utilise le client MSAL pour obtenir un jeton d'accès à l'application uniquement à Microsoft Graph, // et insère ce jeton d'accès dans l'en-tête Authorization de chaque demande d'API. var token = authResult.AccessToken; GraphServiceClient graphServiceClient = new GraphServiceClient(new DelegateAuthenticationProvider(async(requestMessage) => { //Ajoutez le jeton d'accès dans l'en-tête Authorization de la requête API. requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token); }) ); #endregion #region SendMail await graphServiceClient.Me .SendMail(message, false) .Request() .PostAsync(); } #endregion } catch (Exception ex) { Data.Success = false; Data.Messages = ex.Message; } return(Ok(Data)); }
protected void btnSavePDFForm2_Click(object sender, EventArgs e) { try { string tableContent = "["+HdnValue.Value+"]"; string hiddenValue = hdnDescriptionValue.Value; string templateFolderPath = TemplateName; GeneratePDF gPdf = new GeneratePDF(); gPdf.GenerateOrderDetailsPDF(tableContent,hiddenValue,templateFolderPath); } catch (Exception ex) { ProcessException(ex); } }
private void CreateLabel() { try { AddressInfo addInfo = (AddressInfo) Session["sl_toAddress"]; AddressInfo billAddInfo = (AddressInfo) Session["sl_frAddress"]; AspxCommerce.Core.WareHouseAddress whaInfo = GetWareHouseAddress(GetStoreID, GetPortalID); _itemslist = new List<ItemDetail>(); _itemslist = (List<ItemDetail>) Session["sl_items"]; GeneratePDF.BasicPackageInfo basciPagIngo = new GeneratePDF.BasicPackageInfo(); basciPagIngo.TrackingNo = ""; basciPagIngo.TotalWeight = Convert.ToDecimal(lblPackageTotalWeight.Text); basciPagIngo.WeightUnit = lblStoreWeightUnit.Text; basciPagIngo.WaterMark = ""; basciPagIngo.BarcodeNo = ""; basciPagIngo.SenderName = billAddInfo.FirstName + " " + billAddInfo.LastName; basciPagIngo.CautionMessage = "Handle With Care."; basciPagIngo.ServiceType = lblUserShippingMethod.Text; basciPagIngo.Length = Convert.ToInt32(txtPackageLength.Text); basciPagIngo.Width = Convert.ToInt32(txtPackageWidth.Text); basciPagIngo.Height = Convert.ToInt32(txtPackageHeight.Text); basciPagIngo.DimensionUnit = lblStoreDimensionUnit.Text; AspxCommonInfo aspxCommonObj = new AspxCommonInfo(); aspxCommonObj.StoreID = GetStoreID; aspxCommonObj.PortalID = GetPortalID; aspxCommonObj.UserName = GetUsername; aspxCommonObj.CultureName = GetCurrentCultureName; GeneratePDF gPdf = new GeneratePDF(); gPdf.CreateShipmentLabel(addInfo, whaInfo, aspxCommonObj, basciPagIngo); } catch (Exception ex) { throw ex; } }
protected void btnSavePDFForm2_Click(object sender, EventArgs e) { string headerDetail = invoiceHeaderDetails.Value; string tableContent = "[" + HdnValue.Value + "]"; string hdnRemarksData = hdnRemarks.Value; string isMultipleShipping = hdnIsMultipleShipping.Value; string templateFolderPath = TemplateName; GeneratePDF gpdf = new GeneratePDF(); gpdf.GenerateInvoicePDF(headerDetail, tableContent, hdnRemarksData, isMultipleShipping, templateFolderPath); }
//TODO: Remove Theme Param maybe public void CreatePDF(Theme name) { GeneratePDF.GeneratePDFFile(currentThemeTarget.GetQA(), currentThemeTarget.ThemeName, GeneratePDF.DIN.A8); }
public frm_Configuration(GeneratePDF generatePdf) { InitializeComponent(); GeneratePDFBindingSource.DataSource = generatePdf; GeneratePDFBindingSource.EndEdit(); }
public void OnPost() { GeneratePDF.generate(); }